Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set node by name #73

Merged
merged 22 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/failed_tape.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
{
"kind": "set_next_node",
"next_node": 1,
"next_node": "act",
"metadata": {
"agent": "Agent",
"node": "",
Expand Down Expand Up @@ -85,7 +85,7 @@
},
{
"kind": "set_next_node",
"next_node": 1,
"next_node": "act",
"metadata": {
"agent": "Agent",
"node": "",
Expand Down Expand Up @@ -122,7 +122,7 @@
},
{
"kind": "set_next_node",
"next_node": 1,
"next_node": "act",
"metadata": {
"agent": "Agent",
"node": "",
Expand Down
36 changes: 23 additions & 13 deletions examples/gaia_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,34 @@ def prepare_guidance(cls, planning_mode: PlanningMode, subtasks: bool) -> list[G
GaiaNode(name="plan", guidance=PromptRegistry.plan),
GaiaNode(name="facts_survey", guidance=PromptRegistry.facts_survey),
GaiaNode(name="start_execution", guidance=PromptRegistry.start_execution),
GaiaNode(name="default", next_node=3),
GaiaNode(name="default", next_node="default"),
]
elif planning_mode == PlanningMode.reflect:
guidance_nodes = [
GaiaNode(name="plan", guidance=PromptRegistry.plan),
GaiaNode(name="facts_survey", guidance=PromptRegistry.facts_survey),
GaiaNode(name="start_execution", guidance=PromptRegistry.start_execution, next_node=6),
GaiaNode(name="think_after_observation", guidance=PromptRegistry.think_after_observation, next_node=6),
GaiaNode(name="think_after_calculation", guidance=PromptRegistry.think_after_calculation, next_node=6),
GaiaNode(name="default", next_node=6),
GaiaNode(
name="start_execution", guidance=PromptRegistry.start_execution, next_node="after_observation"
),
GaiaNode(
name="think_after_observation",
guidance=PromptRegistry.think_after_observation,
next_node="after_observation",
),
GaiaNode(
name="think_after_calculation",
guidance=PromptRegistry.think_after_calculation,
next_node="after_observation",
),
GaiaNode(name="default", next_node="after_observation"),
ObservationControlNode(
name="node_after_observation",
name="after_observation",
observation_to_node={
PageObservation: 3,
SearchResultsObservation: 3,
CalculationResultObservation: 4,
PageObservation: "think_after_observation",
SearchResultsObservation: "think_after_observation",
CalculationResultObservation: "think_after_calculation",
},
default_node=5,
default_node="default",
),
]
elif planning_mode == PlanningMode.facts_and_sources:
Expand All @@ -149,23 +159,23 @@ def prepare_guidance(cls, planning_mode: PlanningMode, subtasks: bool) -> list[G
GaiaNode(name="facts_survey", guidance=PromptRegistry.facts_survey),
GaiaNode(name="sources_plan", guidance=PromptRegistry.sources_plan),
GaiaNode(name="start_execution", guidance=PromptRegistry.start_execution),
GaiaNode(name="default", next_node=4),
GaiaNode(name="default", next_node="default"),
]
elif planning_mode == PlanningMode.multiplan:
guidance_nodes = [
GaiaNode(name="plan", guidance=PromptRegistry.plan3),
GaiaNode(name="facts_survey", guidance=PromptRegistry.facts_survey),
GaiaNode(name="sources_plan", guidance=PromptRegistry.sources_plan),
GaiaNode(name="start_execution", guidance=PromptRegistry.start_execution),
GaiaNode(name="default", next_node=4),
GaiaNode(name="default", next_node="default"),
]
elif planning_mode == PlanningMode.replan_after_sources:
guidance_nodes = [
GaiaNode(name="plan", guidance=PromptRegistry.plan),
GaiaNode(name="facts_survey", guidance=PromptRegistry.facts_survey),
GaiaNode(name="better_plan", guidance=PromptRegistry.better_plan),
GaiaNode(name="start_execution", guidance=PromptRegistry.start_execution),
GaiaNode(name="default", next_node=4),
GaiaNode(name="default", next_node="default"),
]
else:
raise ValueError(f"Unknown planning mode: {planning_mode}")
Expand Down
2 changes: 1 addition & 1 deletion examples/gsm8k_tuning/math_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def create(cls, llm: LLM):
steps_prompt=ALLOWED_STEPS,
agent_step_cls=MathAgentStep,
guidance=HINTS,
next_node=-1,
next_node="default",
),
],
max_iterations=2,
Expand Down
Loading