Skip to content

Commit 77d140d

Browse files
Refactor RemotePythonExecutor.send_tools to call install_packages (#1281)
1 parent 36783c3 commit 77d140d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/smolagents/remote_executors.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def run_code_raise_errors(self, code: str, return_final_answer: bool = False) ->
5353
raise NotImplementedError
5454

5555
def send_tools(self, tools: dict[str, Tool]):
56-
code = ""
5756
# Install tool packages
5857
packages_to_install = {
5958
pkg
@@ -62,11 +61,9 @@ def send_tools(self, tools: dict[str, Tool]):
6261
if pkg not in self.installed_packages + ["smolagents"]
6362
}
6463
if packages_to_install:
65-
self.installed_packages.extend(packages_to_install)
66-
code += f"!pip install {' '.join(packages_to_install)}\n"
64+
self.installed_packages += self.install_packages(list(packages_to_install))
6765
# Get tool definitions
68-
tool_definition_code = get_tools_definition_code(tools)
69-
code += tool_definition_code
66+
code = get_tools_definition_code(tools)
7067
if code:
7168
execution = self.run_code_raise_errors(code)
7269
self.logger.log(execution[1])

0 commit comments

Comments
 (0)