mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-20 01:59:12 +08:00
fix(planner): skip human feedback if context is sufficient
Change-Id: I2b5628a7a8ecb6a6bad2712a9ff81b9b1cd323c6
This commit is contained in:
parent
eabf1f2080
commit
dab1ba4789
@ -116,6 +116,24 @@ def planner_node(
|
|||||||
logger.debug(f"Current state messages: {state['messages']}")
|
logger.debug(f"Current state messages: {state['messages']}")
|
||||||
logger.info(f"Planner response: {full_response}")
|
logger.info(f"Planner response: {full_response}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
curr_plan = json.loads(repair_json_output(full_response))
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
logger.warning("Planner response is not a valid JSON")
|
||||||
|
if plan_iterations > 0:
|
||||||
|
return Command(goto="reporter")
|
||||||
|
else:
|
||||||
|
return Command(goto="__end__")
|
||||||
|
if curr_plan.get("has_enough_context"):
|
||||||
|
logger.info("Planner response has enough context.")
|
||||||
|
new_plan = Plan.model_validate(curr_plan)
|
||||||
|
return Command(
|
||||||
|
update={
|
||||||
|
"messages": [AIMessage(content=full_response, name="planner")],
|
||||||
|
"current_plan": new_plan,
|
||||||
|
},
|
||||||
|
goto="reporter",
|
||||||
|
)
|
||||||
return Command(
|
return Command(
|
||||||
update={
|
update={
|
||||||
"messages": [AIMessage(content=full_response, name="planner")],
|
"messages": [AIMessage(content=full_response, name="planner")],
|
||||||
|
@ -32,7 +32,7 @@ class Plan(BaseModel):
|
|||||||
thought: str
|
thought: str
|
||||||
title: str
|
title: str
|
||||||
steps: List[Step] = Field(
|
steps: List[Step] = Field(
|
||||||
...,
|
default_factory=list,
|
||||||
description="Research & Processing steps to get more context",
|
description="Research & Processing steps to get more context",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user