mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-15 11:02:36 +02:00
update test
This commit is contained in:
parent
83c8ccb6b9
commit
b0ed292fa7
2 changed files with 15 additions and 5 deletions
|
|
@ -74,6 +74,11 @@ class AmazonProvider(BaseBedrockProvider):
|
|||
|
||||
def _get_completion_from_dict(self, rsp_dict: dict) -> str:
|
||||
return rsp_dict['results'][0]['outputText']
|
||||
|
||||
def get_choice_text_from_stream(self, event) -> str:
|
||||
rsp_dict = json.loads(event["chunk"]["bytes"])
|
||||
completions = rsp_dict["outputText"]
|
||||
return completions
|
||||
|
||||
|
||||
PROVIDERS = {
|
||||
|
|
|
|||
|
|
@ -17,12 +17,17 @@ def mock_bedrock_provider_response(self, *args, **kwargs) -> dict:
|
|||
|
||||
def mock_bedrock_provider_stream_response(self, *args, **kwargs) -> dict:
|
||||
# use json object to mock EventStream
|
||||
def dict2bytes(x):
|
||||
return json.dumps(x).encode("utf-8")
|
||||
provider = self.config.model.split(".")[0]
|
||||
response_body_bytes = json.dumps(
|
||||
BEDROCK_PROVIDER_RESPONSE_BODY[provider]).encode("utf-8")
|
||||
# decoded bytes share the same format as non-stream response_body
|
||||
response_body_stream = {
|
||||
"body": [{'chunk': {'bytes': response_body_bytes}},]}
|
||||
response_body_bytes = dict2bytes(BEDROCK_PROVIDER_RESPONSE_BODY[provider])
|
||||
# decoded bytes share the same format as non-stream response_body except for titan
|
||||
if provider == "amazon":
|
||||
response_body_stream = {
|
||||
"body": [{'chunk': {'bytes': dict2bytes({"outputText": "Hello World"})}}]}
|
||||
else:
|
||||
response_body_stream = {
|
||||
"body": [{'chunk': {'bytes': response_body_bytes}}]}
|
||||
return response_body_stream
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue