Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix python sdk file handling for local testing
Tomas Valentae24fb8a22da7
diff --git a/packages/python-sdk/e2b/constants.py b/packages/python-sdk/e2b/constants.pyindex def45a5b5..1c18a0e9a 100644--- a/packages/python-sdk/e2b/constants.py+++ b/packages/python-sdk/e2b/constants.py@@ -5,3 +5,4 @@ TIMEOUT = 60SESSION_DOMAIN = "ondevbook.com"ENVD_PORT = 49982WS_ROUTE = "/ws"+FILE_ROUTE = "/file"diff --git a/packages/python-sdk/e2b/session/main.py b/packages/python-sdk/e2b/session/main.pyindex 1dc39b85a..47416fa3b 100644--- a/packages/python-sdk/e2b/session/main.py+++ b/packages/python-sdk/e2b/session/main.py@@ -1,11 +1,11 @@import loggingimport urllib.parse+import requests+from os import pathfrom typing import Any, Callable, List, Literal, Optional, Union, IO-import requests--from e2b.constants import TIMEOUT, ENVD_PORT+from e2b.constants import TIMEOUT, ENVD_PORT, FILE_ROUTEfrom e2b.session.code_snippet import CodeSnippetManager, OpenPortfrom e2b.session.env_vars import EnvVarsfrom e2b.session.filesystem import FilesystemManager@@ -156,9 +156,12 @@ class Session(SessionConnection):The file will be uploaded to the user's home directory with the same name.If a file with the same name already exists, it will be overwritten."""- hostname = self.get_hostname(self._debug_port)+ hostname = self.get_hostname(self._debug_port or ENVD_PORT)protocol = "http" if self._debug_dev_env == "local" else "https"- return f"{protocol}://{ENVD_PORT}-{hostname}/file"++ file_url = f"{protocol}://{hostname}{FILE_ROUTE}"++ return file_urldef upload_file(self, file: IO, timeout: Optional[float] = TIMEOUT) -> str:"""