Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,22 +112,7 @@ def pvsnp(problem):
|
|
| 112 |
output.append(message.pretty_print())
|
| 113 |
print (output)'''
|
| 114 |
output = agent.invoke({"messages": "Use tools to answer: "+problem})
|
| 115 |
-
|
| 116 |
-
# Assuming `output` is a JSON-formatted string
|
| 117 |
-
messages = output.get("messages", [])
|
| 118 |
-
answer = None
|
| 119 |
-
for msg in reversed(messages):
|
| 120 |
-
if msg.get("content"):
|
| 121 |
-
answer = msg["content"]
|
| 122 |
-
break
|
| 123 |
-
|
| 124 |
-
# Extract tool names used in tool_calls
|
| 125 |
-
tools_used = []
|
| 126 |
-
for msg in messages:
|
| 127 |
-
if "tool_calls" in msg:
|
| 128 |
-
for tool_call in msg["tool_calls"]:
|
| 129 |
-
tools_used.append(tool_call["name"])
|
| 130 |
-
#response = "Answer: "+answer+'\n'+"Tools used: "+tools_used
|
| 131 |
return answer
|
| 132 |
|
| 133 |
|
|
|
|
| 112 |
output.append(message.pretty_print())
|
| 113 |
print (output)'''
|
| 114 |
output = agent.invoke({"messages": "Use tools to answer: "+problem})
|
| 115 |
+
answer = output['messages'][5]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
return answer
|
| 117 |
|
| 118 |
|