Update app.py
Browse files
app.py
CHANGED
@@ -30,7 +30,13 @@ graph = StateGraph(AgentState)
|
|
30 |
|
31 |
def invoke_model(state):
|
32 |
question = state['messages'][-1]
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|