From 7befaf88250d067794429b18611cb03ee85d2085 Mon Sep 17 00:00:00 2001 From: wujiren <48745614+wujiren@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:32:29 +0800 Subject: [PATCH] Support nested Pydantic model in MarkdownJsonDictParser. (#471) --- src/agentscope/parsers/json_object_parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/agentscope/parsers/json_object_parser.py b/src/agentscope/parsers/json_object_parser.py index 441af8286..6679943a1 100644 --- a/src/agentscope/parsers/json_object_parser.py +++ b/src/agentscope/parsers/json_object_parser.py @@ -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),