I’m experiencing an issue with the agent.python_executor
function in SmolAgents. When I try to run the following code:
agent.python_executor("from helium import *", agent.state)
I get the error:
TypeError: LocalPythonExecutor.__call__() takes 2 positional arguments but 3 were given
I’m following the example from the official documentation (Web Browser Automation with Agents 🤖🌐 ), but I’m still getting this error.
I’ve checked the versions of my dependencies, including SmolAgents and Helium, and they are up to date. I’ve also reviewed my code and can’t find any issues with the logic.
1 Like
It seems that the function specifications have changed without notice…
#agent.python_executor("from helium import *", agent.state)
agent.python_executor("from helium import *")
)
raise InterpreterError(
f"Code execution failed at line '{ast.get_source_segment(code, node)}' due to: {type(e).__name__}: {e}"
)
class PythonExecutor:
pass
class LocalPythonExecutor(PythonExecutor):
def __init__(
self,
additional_authorized_imports: List[str],
max_print_outputs_length: Optional[int] = None,
):
self.custom_tools = {}
self.state = {}
self.max_print_outputs_length = max_print_outputs_length
if max_print_outputs_length is None:
self.max_print_outputs_length = DEFAULT_MAX_LEN_OUTPUT
planning_interval=planning_interval,
**kwargs,
)
if "*" in self.additional_authorized_imports:
self.logger.log(
"Caution: you set an authorization for all imports, meaning your agent can decide to import any package it deems necessary. This might raise issues if the package is not installed in your environment.",
0,
)
self.executor_type = executor_type or "local"
self.executor_kwargs = executor_kwargs or {}
self.python_executor = self.create_python_executor()
def create_python_executor(self) -> PythonExecutor:
match self.executor_type:
case "e2b" | "docker":
if self.managed_agents:
raise Exception("Managed agents are not yet supported with remote code execution.")
if self.executor_type == "e2b":
return E2BExecutor(self.additional_authorized_imports, self.logger, **self.executor_kwargs)
else:
return DockerExecutor(self.additional_authorized_imports, self.logger, **self.executor_kwargs)
1 Like