jcleee commited on
Commit
bba9171
·
verified ·
1 Parent(s): 45ae27a

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +11 -12
Gradio_UI.py CHANGED
@@ -153,29 +153,28 @@ def stream_to_gradio(
153
  ):
154
  yield message
155
 
156
- final_answer = step_log # Last log is the run's final_answer
157
- final_answer = handle_agent_output_types(final_answer)
 
158
 
159
- # Strip any wrapper or formatting for exact match evaluation
160
- if isinstance(final_answer, AgentText):
161
- content = final_answer.to_string().strip()
162
  yield gr.ChatMessage(
163
  role="assistant",
164
- content=content,
165
  )
166
- elif isinstance(final_answer, AgentImage):
167
  yield gr.ChatMessage(
168
  role="assistant",
169
- content={"path": final_answer.to_string(), "mime_type": "image/png"},
170
  )
171
- elif isinstance(final_answer, AgentAudio):
172
  yield gr.ChatMessage(
173
  role="assistant",
174
- content={"path": final_answer.to_string(), "mime_type": "audio/wav"},
175
  )
176
  else:
177
- # Fall back to raw string with no prefix
178
- yield gr.ChatMessage(role="assistant", content=str(final_answer).strip())
179
 
180
 
181
 
 
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
+ final_output = handle_agent_output_types(final_output)
159
 
160
+ if isinstance(final_output, AgentText):
 
 
161
  yield gr.ChatMessage(
162
  role="assistant",
163
+ content=final_output.to_string().strip(),
164
  )
165
+ elif isinstance(final_output, AgentImage):
166
  yield gr.ChatMessage(
167
  role="assistant",
168
+ content={"path": final_output.to_string(), "mime_type": "image/png"},
169
  )
170
+ elif isinstance(final_output, AgentAudio):
171
  yield gr.ChatMessage(
172
  role="assistant",
173
+ content={"path": final_output.to_string(), "mime_type": "audio/wav"},
174
  )
175
  else:
176
+ yield gr.ChatMessage(role="assistant", content=str(final_output).strip())
177
+
178
 
179
 
180