jcleee commited on
Commit
0ae5f1c
·
verified ·
1 Parent(s): 20d3915

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. 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 # this is the final ActionStep
157
- final_output = getattr(final_step, "tool_output", None)
158
 
159
- # If no tool_output, fallback to first final_answer call
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
- final_output = call.arguments.get("answer")
 
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