Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +6 -5
Gradio_UI.py
CHANGED
|
@@ -153,16 +153,17 @@ def stream_to_gradio(
|
|
| 153 |
):
|
| 154 |
yield message
|
| 155 |
|
| 156 |
-
final_step = step_log #
|
| 157 |
-
final_output =
|
| 158 |
|
| 159 |
-
|
| 160 |
-
if not final_output and final_step.tool_calls:
|
| 161 |
for call in final_step.tool_calls:
|
| 162 |
if call.name == "final_answer":
|
| 163 |
-
|
|
|
|
| 164 |
break
|
| 165 |
|
|
|
|
| 166 |
|
| 167 |
final_output = handle_agent_output_types(final_output)
|
| 168 |
|
|
|
|
| 153 |
):
|
| 154 |
yield message
|
| 155 |
|
| 156 |
+
final_step = step_log # last step returned by agent.run()
|
| 157 |
+
final_output = None
|
| 158 |
|
| 159 |
+
if hasattr(final_step, "tool_calls"):
|
|
|
|
| 160 |
for call in final_step.tool_calls:
|
| 161 |
if call.name == "final_answer":
|
| 162 |
+
# Prefer the actual output if available, fallback to arguments
|
| 163 |
+
final_output = call.output if call.output is not None else call.arguments.get("answer")
|
| 164 |
break
|
| 165 |
|
| 166 |
+
|
| 167 |
|
| 168 |
final_output = handle_agent_output_types(final_output)
|
| 169 |
|