mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-19 12:24:46 +08:00
fix: clean up the builder code (#417)
* fix: clean up the builder code * fix:reformat the code
This commit is contained in:
@@ -22,14 +22,23 @@ def continue_to_running_research_team(state: State):
|
|||||||
current_plan = state.get("current_plan")
|
current_plan = state.get("current_plan")
|
||||||
if not current_plan or not current_plan.steps:
|
if not current_plan or not current_plan.steps:
|
||||||
return "planner"
|
return "planner"
|
||||||
|
|
||||||
if all(step.execution_res for step in current_plan.steps):
|
if all(step.execution_res for step in current_plan.steps):
|
||||||
return "planner"
|
return "planner"
|
||||||
|
|
||||||
|
# Find first incomplete step
|
||||||
|
incomplete_step = None
|
||||||
for step in current_plan.steps:
|
for step in current_plan.steps:
|
||||||
if not step.execution_res:
|
if not step.execution_res:
|
||||||
|
incomplete_step = step
|
||||||
break
|
break
|
||||||
if step.step_type and step.step_type == StepType.RESEARCH:
|
|
||||||
|
if not incomplete_step:
|
||||||
|
return "planner"
|
||||||
|
|
||||||
|
if incomplete_step.step_type == StepType.RESEARCH:
|
||||||
return "researcher"
|
return "researcher"
|
||||||
if step.step_type and step.step_type == StepType.PROCESSING:
|
if incomplete_step.step_type == StepType.PROCESSING:
|
||||||
return "coder"
|
return "coder"
|
||||||
return "planner"
|
return "planner"
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,17 @@ def test_continue_to_running_research_team_next_coder(mock_state):
|
|||||||
assert builder_mod.continue_to_running_research_team(state) == "coder"
|
assert builder_mod.continue_to_running_research_team(state) == "coder"
|
||||||
|
|
||||||
|
|
||||||
|
def test_continue_to_running_research_team_next_coder_withresult(mock_state):
|
||||||
|
Step = mock_state["Step"]
|
||||||
|
Plan = mock_state["Plan"]
|
||||||
|
steps = [
|
||||||
|
Step(execution_res=True),
|
||||||
|
Step(execution_res=True, step_type=builder_mod.StepType.PROCESSING),
|
||||||
|
]
|
||||||
|
state = {"current_plan": Plan(steps=steps)}
|
||||||
|
assert builder_mod.continue_to_running_research_team(state) == "planner"
|
||||||
|
|
||||||
|
|
||||||
def test_continue_to_running_research_team_default_planner(mock_state):
|
def test_continue_to_running_research_team_default_planner(mock_state):
|
||||||
Step = mock_state["Step"]
|
Step = mock_state["Step"]
|
||||||
Plan = mock_state["Plan"]
|
Plan = mock_state["Plan"]
|
||||||
|
|||||||
Reference in New Issue
Block a user