Spaces:
Sleeping
Sleeping
Udate app.py
Browse files
app.py
CHANGED
@@ -549,8 +549,31 @@ def tool_node(state: AgentState) -> AgentState:
|
|
549 |
print(f"DEBUG: Exiting tool_node. Tool output added to history. New history length: {len(state['history'])}")
|
550 |
return state
|
551 |
|
|
|
552 |
# ====== Agent Graph ======
|
553 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
|
555 |
# ====== Agent Interface ======
|
556 |
class BasicAgent:
|
|
|
549 |
print(f"DEBUG: Exiting tool_node. Tool output added to history. New history length: {len(state['history'])}")
|
550 |
return state
|
551 |
|
552 |
+
|
553 |
# ====== Agent Graph ======
|
554 |
+
def create_agent_workflow(tools: List[BaseTool]): # Use BaseTool for consistency
|
555 |
+
workflow = StateGraph(AgentState)
|
556 |
+
|
557 |
+
workflow.add_node("reason", reasoning_node)
|
558 |
+
workflow.add_node("action", tool_node)
|
559 |
+
|
560 |
+
workflow.set_entry_point("reason")
|
561 |
+
|
562 |
+
workflow.add_conditional_edges(
|
563 |
+
"reason",
|
564 |
+
should_continue,
|
565 |
+
{
|
566 |
+
"action": "action",
|
567 |
+
"reason": "reason",
|
568 |
+
"end": END
|
569 |
+
}
|
570 |
+
)
|
571 |
+
|
572 |
+
workflow.add_edge("action", "reason")
|
573 |
+
|
574 |
+
app = workflow.compile()
|
575 |
+
return app
|
576 |
+
|
577 |
|
578 |
# ====== Agent Interface ======
|
579 |
class BasicAgent:
|