fix: add model_dump (#137)

Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
This commit is contained in:
Wang Hao 2025-05-16 21:05:46 +08:00 committed by GitHub
parent c3886e635d
commit e27c43f005
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,14 +134,16 @@ def planner_node(
new_plan = Plan.model_validate(curr_plan) new_plan = Plan.model_validate(curr_plan)
return Command( return Command(
update={ update={
"messages": [AIMessage(content=full_response, name="planner")], "messages": [
AIMessage(content=full_response, name="planner").model_dump()
],
"current_plan": new_plan, "current_plan": new_plan,
}, },
goto="reporter", goto="reporter",
) )
return Command( return Command(
update={ update={
"messages": [AIMessage(content=full_response, name="planner")], "messages": [AIMessage(content=full_response, name="planner").model_dump()],
"current_plan": full_response, "current_plan": full_response,
}, },
goto="human_feedback", goto="human_feedback",
@ -162,7 +164,7 @@ def human_feedback_node(
return Command( return Command(
update={ update={
"messages": [ "messages": [
HumanMessage(content=feedback, name="feedback"), HumanMessage(content=feedback, name="feedback").model_dump(),
], ],
}, },
goto="planner", goto="planner",
@ -250,7 +252,7 @@ def reporter_node(state: State):
"messages": [ "messages": [
HumanMessage( HumanMessage(
f"# Research Requirements\n\n## Task\n\n{current_plan.title}\n\n## Description\n\n{current_plan.thought}" f"# Research Requirements\n\n## Task\n\n{current_plan.title}\n\n## Description\n\n{current_plan.thought}"
) ).model_dump()
], ],
"locale": state.get("locale", "en-US"), "locale": state.get("locale", "en-US"),
} }
@ -262,7 +264,7 @@ def reporter_node(state: State):
HumanMessage( HumanMessage(
content="IMPORTANT: Structure your report according to the format in the prompt. Remember to include:\n\n1. Key Points - A bulleted list of the most important findings\n2. Overview - A brief introduction to the topic\n3. Detailed Analysis - Organized into logical sections\n4. Survey Note (optional) - For more comprehensive reports\n5. Key Citations - List all references at the end\n\nFor citations, DO NOT include inline citations in the text. Instead, place all citations in the 'Key Citations' section at the end using the format: `- [Source Title](URL)`. Include an empty line between each citation for better readability.\n\nPRIORITIZE USING MARKDOWN TABLES for data presentation and comparison. Use tables whenever presenting comparative data, statistics, features, or options. Structure tables with clear headers and aligned columns. Example table format:\n\n| Feature | Description | Pros | Cons |\n|---------|-------------|------|------|\n| Feature 1 | Description 1 | Pros 1 | Cons 1 |\n| Feature 2 | Description 2 | Pros 2 | Cons 2 |", content="IMPORTANT: Structure your report according to the format in the prompt. Remember to include:\n\n1. Key Points - A bulleted list of the most important findings\n2. Overview - A brief introduction to the topic\n3. Detailed Analysis - Organized into logical sections\n4. Survey Note (optional) - For more comprehensive reports\n5. Key Citations - List all references at the end\n\nFor citations, DO NOT include inline citations in the text. Instead, place all citations in the 'Key Citations' section at the end using the format: `- [Source Title](URL)`. Include an empty line between each citation for better readability.\n\nPRIORITIZE USING MARKDOWN TABLES for data presentation and comparison. Use tables whenever presenting comparative data, statistics, features, or options. Structure tables with clear headers and aligned columns. Example table format:\n\n| Feature | Description | Pros | Cons |\n|---------|-------------|------|------|\n| Feature 1 | Description 1 | Pros 1 | Cons 1 |\n| Feature 2 | Description 2 | Pros 2 | Cons 2 |",
name="system", name="system",
) ).model_dump()
) )
for observation in observations: for observation in observations:
@ -270,7 +272,7 @@ def reporter_node(state: State):
HumanMessage( HumanMessage(
content=f"Below are some observations for the research task:\n\n{observation}", content=f"Below are some observations for the research task:\n\n{observation}",
name="observation", name="observation",
) ).model_dump()
) )
logger.debug(f"Current invoke messages: {invoke_messages}") logger.debug(f"Current invoke messages: {invoke_messages}")
response = get_llm_by_type(AGENT_LLM_MAP["reporter"]).invoke(invoke_messages) response = get_llm_by_type(AGENT_LLM_MAP["reporter"]).invoke(invoke_messages)
@ -336,7 +338,7 @@ async def _execute_agent_step(
"messages": [ "messages": [
HumanMessage( HumanMessage(
content=f"{completed_steps_info}# Current Task\n\n## Title\n\n{current_step.title}\n\n## Description\n\n{current_step.description}\n\n## Locale\n\n{state.get('locale', 'en-US')}" content=f"{completed_steps_info}# Current Task\n\n## Title\n\n{current_step.title}\n\n## Description\n\n{current_step.description}\n\n## Locale\n\n{state.get('locale', 'en-US')}"
) ).model_dump()
] ]
} }
@ -346,7 +348,7 @@ async def _execute_agent_step(
HumanMessage( HumanMessage(
content="IMPORTANT: DO NOT include inline citations in the text. Instead, track all sources and include a References section at the end using link reference format. Include an empty line between each citation for better readability. Use this format for each reference:\n- [Source Title](URL)\n\n- [Another Source](URL)", content="IMPORTANT: DO NOT include inline citations in the text. Instead, track all sources and include a References section at the end using link reference format. Include an empty line between each citation for better readability. Use this format for each reference:\n- [Source Title](URL)\n\n- [Another Source](URL)",
name="system", name="system",
) ).model_dump()
) )
# Invoke the agent # Invoke the agent
@ -366,7 +368,7 @@ async def _execute_agent_step(
HumanMessage( HumanMessage(
content=response_content, content=response_content,
name=agent_name, name=agent_name,
) ).model_dump(),
], ],
"observations": observations + [response_content], "observations": observations + [response_content],
}, },