Update app.py
Browse files
app.py
CHANGED
|
@@ -47,8 +47,12 @@ graph.add_edge("tool", END)
|
|
| 47 |
graph.set_entry_point("agent")
|
| 48 |
|
| 49 |
def router(state):
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
graph.add_conditional_edges("agent", router, {"multiply": "tool", "end": END})
|
| 54 |
app_graph = graph.compile()
|
|
|
|
| 47 |
graph.set_entry_point("agent")
|
| 48 |
|
| 49 |
def router(state):
|
| 50 |
+
tool_calls = state['messages'][-1].additional_kwargs.get("tool_calls", [])
|
| 51 |
+
if len(tool_calls): # Check if tool_calls exist
|
| 52 |
+
return "multiply" # Route to the tool node
|
| 53 |
+
else:
|
| 54 |
+
return "end" # Route to the end node
|
| 55 |
+
|
| 56 |
|
| 57 |
graph.add_conditional_edges("agent", router, {"multiply": "tool", "end": END})
|
| 58 |
app_graph = graph.compile()
|