From 6b52ee3e7c2a6d78c9552d3bb3b1e67fbbb1486f Mon Sep 17 00:00:00 2001 From: better629 Date: Mon, 15 Jan 2024 20:10:39 +0800 Subject: [PATCH 1/4] fix UserWarning: Pydantic serializer warning Expected str but got dict --- metagpt/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/schema.py b/metagpt/schema.py index 853a9c6bb..c0f867831 100644 --- a/metagpt/schema.py +++ b/metagpt/schema.py @@ -212,7 +212,7 @@ class Message(BaseModel): return any_to_str_set(send_to if send_to else {MESSAGE_ROUTE_TO_ALL}) @field_serializer("instruct_content", mode="plain") - def ser_instruct_content(self, ic: BaseModel) -> Union[str, None]: + def ser_instruct_content(self, ic: BaseModel) -> Union[dict, None]: ic_dict = None if ic: # compatible with custom-defined ActionOutput From 465279dfcc3fb5f75c7b4cda9349af558f1ad590 Mon Sep 17 00:00:00 2001 From: better629 Date: Mon, 15 Jan 2024 20:22:04 +0800 Subject: [PATCH 2/4] update unittest due to implement update --- tests/metagpt/serialize_deserialize/test_write_prd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/metagpt/serialize_deserialize/test_write_prd.py b/tests/metagpt/serialize_deserialize/test_write_prd.py index 820ee237c..945ec5efd 100644 --- a/tests/metagpt/serialize_deserialize/test_write_prd.py +++ b/tests/metagpt/serialize_deserialize/test_write_prd.py @@ -18,5 +18,5 @@ async def test_action_serdeser(new_filename): new_action = WritePRD(**ser_action_dict) assert new_action.name == "WritePRD" - action_output = await new_action.run(with_messages=Message(content="write a cli snake game")) - assert len(action_output.content) > 0 + with pytest.raises(FileNotFoundError): + action_output = await new_action.run(with_messages=Message(content="write a cli snake game")) From b800e57def0c40986c0d3993a672c5a57fa9dd10 Mon Sep 17 00:00:00 2001 From: better629 Date: Mon, 15 Jan 2024 20:23:46 +0800 Subject: [PATCH 3/4] fix format --- metagpt/actions/action_node.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/metagpt/actions/action_node.py b/metagpt/actions/action_node.py index 4f61af4ed..ca41c76a5 100644 --- a/metagpt/actions/action_node.py +++ b/metagpt/actions/action_node.py @@ -469,8 +469,10 @@ class ActionNode: return dict() prompt = template.format( - nodes_output=json.dumps(nodes_output, ensure_ascii=False), tag=TAG, constraint=FORMAT_CONSTRAINT, - prompt_schema="json" + nodes_output=json.dumps(nodes_output, ensure_ascii=False), + tag=TAG, + constraint=FORMAT_CONSTRAINT, + prompt_schema="json", ) content = await self.llm.aask(prompt) @@ -568,7 +570,7 @@ class ActionNode: example=example, instruction=instruction, constraint=FORMAT_CONSTRAINT, - prompt_schema="json" + prompt_schema="json", ) # step2, use `_aask_v1` to get revise structure result From 7ffb2208e21248a73c04cbdff11282d447f1c016 Mon Sep 17 00:00:00 2001 From: better629 Date: Mon, 15 Jan 2024 20:24:43 +0800 Subject: [PATCH 4/4] fix format --- tests/metagpt/serialize_deserialize/test_write_prd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/metagpt/serialize_deserialize/test_write_prd.py b/tests/metagpt/serialize_deserialize/test_write_prd.py index 945ec5efd..afc483e9a 100644 --- a/tests/metagpt/serialize_deserialize/test_write_prd.py +++ b/tests/metagpt/serialize_deserialize/test_write_prd.py @@ -19,4 +19,4 @@ async def test_action_serdeser(new_filename): new_action = WritePRD(**ser_action_dict) assert new_action.name == "WritePRD" with pytest.raises(FileNotFoundError): - action_output = await new_action.run(with_messages=Message(content="write a cli snake game")) + await new_action.run(with_messages=Message(content="write a cli snake game"))