max-kwon Claude Opus 5.5 (1M context) commited on
Commit
10ca06f
·
1 Parent(s): 3e2a390

Unwrap FinalAnswerStep before rendering final answer in Gradio UI

Browse files

smolagents 1.13 yields the final answer wrapped in FinalAnswerStep, so
images fell through to the text branch and were shown as a repr string.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. Gradio_UI.py +2 -2
Gradio_UI.py CHANGED
@@ -21,7 +21,7 @@ from typing import Optional
21
 
22
  from smolagents.agent_types import AgentAudio, AgentImage, AgentText, handle_agent_output_types
23
  from smolagents.agents import ActionStep, MultiStepAgent
24
- from smolagents.memory import MemoryStep
25
  from smolagents.utils import _is_package_available
26
 
27
 
@@ -153,7 +153,7 @@ 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
  if isinstance(final_answer, AgentText):
 
21
 
22
  from smolagents.agent_types import AgentAudio, AgentImage, AgentText, handle_agent_output_types
23
  from smolagents.agents import ActionStep, MultiStepAgent
24
+ from smolagents.memory import FinalAnswerStep, MemoryStep
25
  from smolagents.utils import _is_package_available
26
 
27
 
 
153
  ):
154
  yield message
155
 
156
+ final_answer = step_log.final_answer if isinstance(step_log, FinalAnswerStep) else step_log # Last log is the run's final_answer
157
  final_answer = handle_agent_output_types(final_answer)
158
 
159
  if isinstance(final_answer, AgentText):