Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -194,6 +194,13 @@ class GaiaAgentState(TypedDict):
|
|
| 194 |
plan: List[Dict[str, Any]]
|
| 195 |
tool_results: List[Any]
|
| 196 |
final_answer: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
# === 2. TOOL STUBS ===
|
| 199 |
|
|
@@ -432,12 +439,14 @@ class EsiAgent:
|
|
| 432 |
def __init__(self):
|
| 433 |
# 1. Build & compile your graph
|
| 434 |
builder = StateGraph(GaiaAgentState)
|
| 435 |
-
|
|
|
|
| 436 |
builder.add_node("planner", planner_node)
|
| 437 |
builder.add_node("execute", tool_executor)
|
| 438 |
builder.add_node("synthesize", synthesizer)
|
| 439 |
-
|
| 440 |
-
builder.add_edge(START, "
|
|
|
|
| 441 |
builder.add_edge("planner", "execute")
|
| 442 |
builder.add_edge("execute", "synthesize")
|
| 443 |
builder.add_edge("synthesize", END)
|
|
@@ -460,11 +469,23 @@ class EsiAgent:
|
|
| 460 |
"files": files or [],
|
| 461 |
"level": level
|
| 462 |
}
|
| 463 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
|
| 465 |
# 2) Wrap in your custom state class
|
| 466 |
state = GaiaAgentState(raw_payload=payload)
|
| 467 |
-
|
|
|
|
|
|
|
| 468 |
# 3) Invoke the graph end-to-end
|
| 469 |
final_state = self.graph.invoke(state)
|
| 470 |
|
|
|
|
| 194 |
plan: List[Dict[str, Any]]
|
| 195 |
tool_results: List[Any]
|
| 196 |
final_answer: str
|
| 197 |
+
|
| 198 |
+
def input_parser(state: GaiaAgentState) -> dict:
|
| 199 |
+
return {
|
| 200 |
+
"question": state.raw_payload["question"],
|
| 201 |
+
"files": state.raw_payload.get("files", []),
|
| 202 |
+
"level": state.raw_payload.get("level", 1)
|
| 203 |
+
}
|
| 204 |
|
| 205 |
# === 2. TOOL STUBS ===
|
| 206 |
|
|
|
|
| 439 |
def __init__(self):
|
| 440 |
# 1. Build & compile your graph
|
| 441 |
builder = StateGraph(GaiaAgentState)
|
| 442 |
+
|
| 443 |
+
builder.add_node("parse", input_parser)
|
| 444 |
builder.add_node("planner", planner_node)
|
| 445 |
builder.add_node("execute", tool_executor)
|
| 446 |
builder.add_node("synthesize", synthesizer)
|
| 447 |
+
|
| 448 |
+
builder.add_edge(START, "parse")
|
| 449 |
+
builder.add_edge("parse", "planner")
|
| 450 |
builder.add_edge("planner", "execute")
|
| 451 |
builder.add_edge("execute", "synthesize")
|
| 452 |
builder.add_edge("synthesize", END)
|
|
|
|
| 469 |
"files": files or [],
|
| 470 |
"level": level
|
| 471 |
}
|
| 472 |
+
# initial = {
|
| 473 |
+
# "question": question,
|
| 474 |
+
# "files": [], # or your file list
|
| 475 |
+
# "level": 1,
|
| 476 |
+
# "task_id": 1,
|
| 477 |
+
# "plan": [], # planner_node will overwrite this
|
| 478 |
+
# "tool_results": [] # executor will overwrite this
|
| 479 |
+
# "final_answer": ""
|
| 480 |
+
# }
|
| 481 |
+
|
| 482 |
+
# print(2222222222, payload)
|
| 483 |
|
| 484 |
# 2) Wrap in your custom state class
|
| 485 |
state = GaiaAgentState(raw_payload=payload)
|
| 486 |
+
# state = GaiaAgentState(dict)
|
| 487 |
+
|
| 488 |
+
print(6666666666666, state)
|
| 489 |
# 3) Invoke the graph end-to-end
|
| 490 |
final_state = self.graph.invoke(state)
|
| 491 |
|