wt002 commited on
Commit
f8fb884
·
verified ·
1 Parent(s): 770fff9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -267,16 +267,14 @@ class BasicAgent:
267
  python_execution
268
  ]
269
 
 
270
  def __call__(self, question: str) -> str:
271
- state = init_state(question)
272
- final_state = self.workflow.invoke(state)
273
-
274
- # Extract final answer
275
- for msg in reversed(final_state['history']):
276
- if msg.get('content', '').startswith("FINAL ANSWER:"):
277
- return msg['content'].split("FINAL ANSWER:")[1].strip()
278
-
279
- return "No final answer found"
280
 
281
 
282
 
 
267
  python_execution
268
  ]
269
 
270
+
271
  def __call__(self, question: str) -> str:
272
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
273
+ # Wrap the question in a HumanMessage from langchain_core
274
+ messages = [HumanMessage(content=question)]
275
+ messages = self.graph.invoke({"messages": messages})
276
+ answer = messages['messages'][-1].content
277
+ return answer[14:]
 
 
 
278
 
279
 
280