Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -270,16 +270,29 @@ class BasicAgent:
|
|
270 |
|
271 |
|
272 |
def __call__(self, question: str) -> str:
|
|
|
|
|
|
|
273 |
state = init_state(question)
|
|
|
|
|
274 |
final_state = self.workflow.invoke(state)
|
275 |
|
276 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
for msg in reversed(final_state['history']):
|
278 |
if isinstance(msg, AIMessage) and "FINAL ANSWER:" in msg.content:
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
|
|
283 |
|
284 |
|
285 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
270 |
|
271 |
|
272 |
def __call__(self, question: str) -> str:
|
273 |
+
print(f"Agent received question: {question[:50]}{'...' if len(question) > 50 else ''}")
|
274 |
+
|
275 |
+
# Initialize state with the question
|
276 |
state = init_state(question)
|
277 |
+
|
278 |
+
# Execute the workflow
|
279 |
final_state = self.workflow.invoke(state)
|
280 |
|
281 |
+
# Debug: Print the final state structure
|
282 |
+
print(f"Final state keys: {list(final_state.keys())}")
|
283 |
+
if 'history' in final_state:
|
284 |
+
print(f"History length: {len(final_state['history'])}")
|
285 |
+
for i, msg in enumerate(final_state['history']):
|
286 |
+
print(f"Message {i}: {type(msg).__name__} - {msg.content[:100]}...")
|
287 |
+
|
288 |
+
# Extract final answer from history
|
289 |
for msg in reversed(final_state['history']):
|
290 |
if isinstance(msg, AIMessage) and "FINAL ANSWER:" in msg.content:
|
291 |
+
# Extract and clean the final answer
|
292 |
+
answer = msg.content.split("FINAL ANSWER:")[1].strip()
|
293 |
+
print(f"Agent returning answer: {answer}")
|
294 |
+
return answer
|
295 |
+
|
296 |
|
297 |
|
298 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|