Skip to content

Commit a7315b4

Browse files
authored
fix: solves the malformed json output and pydantic validation error produced by the 'planner' node by forcing the llm response to strictly comply with the pydantic 'Plan' model (bytedance#322)
1 parent 03e6a1a commit a7315b4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/graph/nodes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def planner_node(
104104
if AGENT_LLM_MAP["planner"] == "basic":
105105
llm = get_llm_by_type(AGENT_LLM_MAP["planner"]).with_structured_output(
106106
Plan,
107-
method="json_mode",
107+
method="json_schema",
108+
strict=True,
108109
)
109110
else:
110111
llm = get_llm_by_type(AGENT_LLM_MAP["planner"])

0 commit comments

Comments
 (0)