Merge pull request #758 from better629/dev

Feat fix UserWarning: Pydantic serializer warning Expected str but got dict
This commit is contained in:
geekan 2024-01-15 21:11:38 +08:00 committed by GitHub
commit b0af1e88ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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"))