Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small tweaks to Gradio demo #93

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/smolagents/gradio_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
def pull_messages_from_step(step_log: AgentStep, test_mode: bool = True):
"""Extract ChatMessage objects from agent steps"""
if isinstance(step_log, ActionStep):
yield gr.ChatMessage(role="assistant", content=step_log.llm_output)
yield gr.ChatMessage(role="assistant", content=step_log.llm_output or "")
if step_log.tool_call is not None:
used_code = step_log.tool_call.name == "code interpreter"
content = step_log.tool_call.arguments
Expand All @@ -36,7 +36,7 @@ def pull_messages_from_step(step_log: AgentStep, test_mode: bool = True):
)
if step_log.observations is not None:
yield gr.ChatMessage(
role="assistant", content=f"```\n{step_log.observations}\n```"
role="assistant", content=step_log.observations
)
if step_log.error is not None:
yield gr.ChatMessage(
Expand Down Expand Up @@ -65,7 +65,7 @@ def stream_to_gradio(
if isinstance(final_answer, AgentText):
yield gr.ChatMessage(
role="assistant",
content=f"**Final answer:**\n```\n{final_answer.to_string()}\n```",
content=f"**Final answer:**\n{final_answer.to_string()}\n",
)
elif isinstance(final_answer, AgentImage):
yield gr.ChatMessage(
Expand Down
Loading