From 27d947bb467c11be8ffd8dbebabfc6cdf14e017f Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Tue, 28 Jan 2025 17:15:14 -0800 Subject: [PATCH 1/4] Fix return type of generator function in `Agent._run()` --- src/smolagents/agents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smolagents/agents.py b/src/smolagents/agents.py index c9decd93d..f450aaeed 100644 --- a/src/smolagents/agents.py +++ b/src/smolagents/agents.py @@ -564,7 +564,7 @@ def run( # Outputs are returned only at the end as a string. We only look at the last step return deque(self._run(task=self.task, images=images), maxlen=1)[0] - def _run(self, task: str, images: List[str] | None = None) -> Generator[str, None, None]: + def _run(self, task: str, images: List[str] | None = None) -> Generator[ActionStep, None, None]: """ Run the agent in streaming mode and returns a generator of all the steps. From 4a46d9deff57493b34be669351859a846797bcad Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Tue, 28 Jan 2025 17:29:43 -0800 Subject: [PATCH 2/4] Update src/smolagents/agents.py --- src/smolagents/agents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smolagents/agents.py b/src/smolagents/agents.py index f450aaeed..5059fd260 100644 --- a/src/smolagents/agents.py +++ b/src/smolagents/agents.py @@ -564,7 +564,7 @@ def run( # Outputs are returned only at the end as a string. We only look at the last step return deque(self._run(task=self.task, images=images), maxlen=1)[0] - def _run(self, task: str, images: List[str] | None = None) -> Generator[ActionStep, None, None]: + def _run(self, task: str, images: List[str] | None = None) -> Generator[ActionStep | AgentType, None, None]: """ Run the agent in streaming mode and returns a generator of all the steps. From 46e5aa95add9792f42a9a919d805db3217e13fe7 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Tue, 28 Jan 2025 18:41:00 -0800 Subject: [PATCH 3/4] Update agents.py --- src/smolagents/agents.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/smolagents/agents.py b/src/smolagents/agents.py index 5059fd260..d2c916370 100644 --- a/src/smolagents/agents.py +++ b/src/smolagents/agents.py @@ -57,7 +57,12 @@ Tool, get_tool_description_with_args, ) -from .types import AgentAudio, AgentImage, handle_agent_output_types +from .types import ( + AgentAudio, + AgentImage, + AgentType, + handle_agent_output_types +) from .utils import ( AgentError, AgentExecutionError, From 4b4b5a5b7ffb9a977c118cb8ea9b33d56ddb0074 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Tue, 28 Jan 2025 18:45:14 -0800 Subject: [PATCH 4/4] fix --- src/smolagents/agents.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/smolagents/agents.py b/src/smolagents/agents.py index d2c916370..12a85693e 100644 --- a/src/smolagents/agents.py +++ b/src/smolagents/agents.py @@ -57,12 +57,7 @@ Tool, get_tool_description_with_args, ) -from .types import ( - AgentAudio, - AgentImage, - AgentType, - handle_agent_output_types -) +from .types import AgentAudio, AgentImage, AgentType, handle_agent_output_types from .utils import ( AgentError, AgentExecutionError,