8000 Support images in stream_to_gradio by aymeric-roucher · Pull Request #1154 · huggingface/smolagents · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support images in stream_to_gradio #1154

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

Merged
merged 2 commits into from
Apr 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
5 changes: 4 additions & 1 deletion src/smolagents/gradio_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,17 @@ def pull_messages_from_step(
def stream_to_gradio(
agent,
task: str,
task_images: list | None = None,
reset_agent_memory: bool = False,
additional_args: Optional[dict] = None,
):
"""Runs an agent with the given task and streams the messages from the agent as gradio ChatMessages."""
total_input_tokens = 0
total_output_tokens = 0

for step_log in agent.run(task, stream=True, reset=reset_agent_memory, additional_args=additional_args):
for step_log in agent.run(
task, images=task_images, stream=True, reset=reset_agent_memory, additional_args=additional_args
):
# Track tokens if model provides them
if getattr(agent.model, "last_input_token_count", None) is not None:
total_input_tokens += agent.model.last_input_token_count
Expand Down
0