|
19 | 19 | import mimetypes
|
20 | 20 | import re
|
21 | 21 |
|
22 |
| -from .agents import ActionStep, AgentStep, MultiStepAgent |
| 22 | +from typing import Optional |
| 23 | + |
| 24 | +from .agents import ActionStep, AgentStepLog, MultiStepAgent |
23 | 25 | from .types import AgentAudio, AgentImage, AgentText, handle_agent_output_types
|
24 | 26 |
|
25 | 27 |
|
26 |
| -def pull_messages_from_step(step_log: AgentStep, test_mode: bool = True): |
| 28 | +def pull_messages_from_step(step_log: AgentStepLog, test_mode: bool = True): |
27 | 29 | """Extract ChatMessage objects from agent steps"""
|
28 | 30 | if isinstance(step_log, ActionStep):
|
29 | 31 | yield gr.ChatMessage(role="assistant", content=step_log.llm_output or "")
|
@@ -53,11 +55,13 @@ def stream_to_gradio(
|
53 | 55 | task: str,
|
54 | 56 | test_mode: bool = False,
|
55 | 57 | reset_agent_memory: bool = False,
|
56 |
| - **kwargs, |
| 58 | + additional_args: Optional[dict] = None, |
57 | 59 | ):
|
58 | 60 | """Runs an agent with the given task and streams the messages from the agent as gradio ChatMessages."""
|
59 | 61 |
|
60 |
| - for step_log in agent.run(task, stream=True, reset=reset_agent_memory, **kwargs): |
| 62 | + for step_log in agent.run( |
| 63 | + task, stream=True, reset=reset_agent_memory, additional_args=additional_args |
| 64 | + ): |
61 | 65 | for message in pull_messages_from_step(step_log, test_mode=test_mode):
|
62 | 66 | yield message
|
63 | 67 |
|
@@ -172,7 +176,7 @@ def launch(self):
|
172 | 176 | type="messages",
|
173 | 177 | avatar_images=(
|
174 | 178 | None,
|
175 |
| - "https://em-content.zobj.net/source/twitter/53/robot-face_1f916.png", |
| 179 | + "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/smolagents/mascot_smol.png", |
176 | 180 | ),
|
177 | 181 | )
|
178 | 182 | # If an upload folder is provided, enable the upload feature
|
|
0 commit comments