DrishtiSharma commited on
Commit
20d5bf2
·
verified ·
1 Parent(s): e19b96d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -30,7 +30,13 @@ graph = StateGraph(AgentState)
30
 
31
  def invoke_model(state):
32
  question = state['messages'][-1]
33
- return {"messages": [model_with_tools.invoke(question)]}
 
 
 
 
 
 
34
 
35
  graph.add_node("agent", invoke_model)
36
 
 
30
 
31
  def invoke_model(state):
32
  question = state['messages'][-1]
33
+ response = model_with_tools.invoke(question)
34
+ # If no tool calls are found, return the raw response content
35
+ if not response.additional_kwargs.get("tool_calls", []):
36
+ return {"messages": [response.content]}
37
+ # Otherwise, return the response object as before
38
+ return {"messages": [response]}
39
+
40
 
41
  graph.add_node("agent", invoke_model)
42