DrishtiSharma commited on
Commit
1a67ad9
·
verified ·
1 Parent(s): 737e35e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -47,8 +47,12 @@ graph.add_edge("tool", END)
47
  graph.set_entry_point("agent")
48
 
49
  def router(state):
50
- calls = state['messages'][-1].additional_kwargs.get("tool_calls", [])
51
- return "multiply" if calls else "end"
 
 
 
 
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()