Skip to content

Commit fdf4fe4

Browse files
Fix additional args in stream_to_gradio (#221)
1 parent 2a69f15 commit fdf4fe4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/smolagents/agents.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ class ToolCall:
7575
id: str
7676

7777

78-
class AgentStep:
78+
class AgentStepLog:
7979
pass
8080

8181

8282
@dataclass
83-
class ActionStep(AgentStep):
83+
class ActionStep(AgentStepLog):
8484
agent_memory: List[Dict[str, str]] | None = None
8585
tool_calls: List[ToolCall] | None = None
8686
start_time: float | None = None
@@ -94,18 +94,18 @@ class ActionStep(AgentStep):
9494

9595

9696
@dataclass
97-
class PlanningStep(AgentStep):
97+
class PlanningStep(AgentStepLog):
9898
plan: str
9999
facts: str
100100

101101

102102
@dataclass
103-
class TaskStep(AgentStep):
103+
class TaskStep(AgentStepLog):
104104
task: str
105105

106106

107107
@dataclass
108-
class SystemPromptStep(AgentStep):
108+
class SystemPromptStep(AgentStepLog):
109109
system_prompt: str
110110

111111

src/smolagents/gradio_ui.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
import mimetypes
2020
import re
2121

22-
from .agents import ActionStep, AgentStep, MultiStepAgent
22+
from typing import Optional
23+
24+
from .agents import ActionStep, AgentStepLog, MultiStepAgent
2325
from .types import AgentAudio, AgentImage, AgentText, handle_agent_output_types
2426

2527

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):
2729
"""Extract ChatMessage objects from agent steps"""
2830
if isinstance(step_log, ActionStep):
2931
yield gr.ChatMessage(role="assistant", content=step_log.llm_output or "")
@@ -53,11 +55,13 @@ def stream_to_gradio(
5355
task: str,
5456
test_mode: bool = False,
5557
reset_agent_memory: bool = False,
56-
**kwargs,
58+
additional_args: Optional[dict] = None,
5759
):
5860
"""Runs an agent with the given task and streams the messages from the agent as gradio ChatMessages."""
5961

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+
):
6165
for message in pull_messages_from_step(step_log, test_mode=test_mode):
6266
yield message
6367

@@ -172,7 +176,7 @@ def launch(self):
172176
type="messages",
173177
avatar_images=(
174178
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",
176180
),
177181
)
178182
# If an upload folder is provided, enable the upload feature

0 commit comments

Comments
 (0)