AI-Quotient commited on
Commit
e4cdfc9
·
verified ·
1 Parent(s): 0d10f9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -114,10 +114,7 @@ def pvsnp(problem):
114
  output = agent.invoke({"messages": "Use tools to answer: "+problem})
115
 
116
  # Assuming `output` is a JSON-formatted string
117
- data = json.loads(output)
118
-
119
- # Extract the answer from the final AIMessage
120
- messages = data.get("messages", [])
121
  answer = None
122
  for msg in reversed(messages):
123
  if msg.get("content"):
@@ -130,11 +127,8 @@ def pvsnp(problem):
130
  if "tool_calls" in msg:
131
  for tool_call in msg["tool_calls"]:
132
  tools_used.append(tool_call["name"])
133
-
134
- print("Answer:", answer)
135
- print("Tools used:", tools_used)
136
- response = "Answer: "+answer+'\n'+"Tools used: "+tools_used
137
- return response
138
 
139
 
140
  iface = gr.Interface(
 
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"):
 
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
 
134
  iface = gr.Interface(