Skip to content

Commit

Permalink
Support nested Pydantic model in MarkdownJsonDictParser. (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
wujiren authored Oct 28, 2024
1 parent eeee97a commit 7befaf8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/agentscope/parsers/json_object_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ def parse(self, response: ModelResponse) -> ModelResponse:
# Requirement checking by Pydantic
if self.pydantic_class is not None:
try:
response.parsed = dict(self.pydantic_class(**response.parsed))
response.parsed = self.pydantic_class(
**response.parsed,
).model_dump()
except Exception as e:
raise JsonParsingError(
message=str(e),
Expand Down

0 comments on commit 7befaf8

Please sign in to comment.