Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -401,7 +401,7 @@ FINAL ANSWER: [Your conclusive answer]"""
|
|
| 401 |
return Answer(
|
| 402 |
text="Maximum steps reached without conclusive answer",
|
| 403 |
confidence=0.0,
|
| 404 |
-
reasoning_trace=
|
| 405 |
tools_used=self.state.tools_used,
|
| 406 |
processing_time=(datetime.now() - start_time).total_seconds()
|
| 407 |
)
|
|
@@ -411,7 +411,7 @@ FINAL ANSWER: [Your conclusive answer]"""
|
|
| 411 |
return Answer(
|
| 412 |
text=f"Error processing question: {str(e)}",
|
| 413 |
confidence=0.0,
|
| 414 |
-
reasoning_trace=[],
|
| 415 |
tools_used=[],
|
| 416 |
processing_time=(datetime.now() - start_time).total_seconds()
|
| 417 |
)
|
|
@@ -454,10 +454,28 @@ FINAL ANSWER: [Your conclusive answer]"""
|
|
| 454 |
|
| 455 |
# If we have a final answer, construct and return it
|
| 456 |
if parsed.get('final_answer'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
return Answer(
|
| 458 |
text=parsed['final_answer'],
|
| 459 |
confidence=parsed.get('confidence', 0.0),
|
| 460 |
-
reasoning_trace=
|
| 461 |
tools_used=self.state.tools_used,
|
| 462 |
processing_time=0.0, # Will be updated in process_question
|
| 463 |
metadata={'memory_used': bool(self.state.memory)}
|
|
|
|
| 401 |
return Answer(
|
| 402 |
text="Maximum steps reached without conclusive answer",
|
| 403 |
confidence=0.0,
|
| 404 |
+
reasoning_trace=["Maximum number of steps reached without finding an answer"],
|
| 405 |
tools_used=self.state.tools_used,
|
| 406 |
processing_time=(datetime.now() - start_time).total_seconds()
|
| 407 |
)
|
|
|
|
| 411 |
return Answer(
|
| 412 |
text=f"Error processing question: {str(e)}",
|
| 413 |
confidence=0.0,
|
| 414 |
+
reasoning_trace=["Error occurred during processing"],
|
| 415 |
tools_used=[],
|
| 416 |
processing_time=(datetime.now() - start_time).total_seconds()
|
| 417 |
)
|
|
|
|
| 454 |
|
| 455 |
# If we have a final answer, construct and return it
|
| 456 |
if parsed.get('final_answer'):
|
| 457 |
+
# Extract reasoning traces as strings
|
| 458 |
+
reasoning_trace = []
|
| 459 |
+
for step in self.state.intermediate_results:
|
| 460 |
+
# Add reasoning from the step
|
| 461 |
+
if step.get('reasoning'):
|
| 462 |
+
reasoning_trace.extend(step['reasoning'])
|
| 463 |
+
# Add tool results if any
|
| 464 |
+
if step.get('tool_results'):
|
| 465 |
+
for tool_result in step['tool_results']:
|
| 466 |
+
if tool_result['status'] == 'success':
|
| 467 |
+
reasoning_trace.append(
|
| 468 |
+
f"Tool {tool_result['tool']} result: {str(tool_result['result'])}"
|
| 469 |
+
)
|
| 470 |
+
else:
|
| 471 |
+
reasoning_trace.append(
|
| 472 |
+
f"Tool {tool_result['tool']} error: {tool_result.get('error', 'unknown error')}"
|
| 473 |
+
)
|
| 474 |
+
|
| 475 |
return Answer(
|
| 476 |
text=parsed['final_answer'],
|
| 477 |
confidence=parsed.get('confidence', 0.0),
|
| 478 |
+
reasoning_trace=reasoning_trace, # Now properly formatted as list of strings
|
| 479 |
tools_used=self.state.tools_used,
|
| 480 |
processing_time=0.0, # Will be updated in process_question
|
| 481 |
metadata={'memory_used': bool(self.state.memory)}
|