mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
Merge pull request #758 from better629/dev
Feat fix UserWarning: Pydantic serializer warning Expected str but got dict
This commit is contained in:
commit
b0af1e88ac
3 changed files with 8 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -232,7 +232,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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
await new_action.run(with_messages=Message(content="write a cli snake game"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue