e2b-code-interpreter 2.6.0__tar.gz → 2.6.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: e2b-code-interpreter
3
- Version: 2.6.0
3
+ Version: 2.6.2
4
4
  Summary: E2B Code Interpreter - Stateful code execution
5
5
  Home-page: https://e2b.dev/
6
6
  License: MIT
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Requires-Dist: attrs (>=21.3.0)
17
- Requires-Dist: e2b (>=2.7.0,<3.0.0)
17
+ Requires-Dist: e2b (>=2.20.3,<3.0.0)
18
18
  Requires-Dist: httpx (>=0.20.0,<1.0.0)
19
19
  Project-URL: Bug Tracker, https://github.com/e2b-dev/code-interpreter/issues
20
20
  Project-URL: Repository, https://github.com/e2b-dev/code-interpreter/tree/main/python
@@ -10,4 +10,5 @@ from .models import (
10
10
  Logs,
11
11
  OutputHandler,
12
12
  OutputMessage,
13
+ RunCodeLanguage,
13
14
  )
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  import httpx
3
3
 
4
- from typing import Optional, Dict, overload, Union, Literal, List
4
+ from typing import Optional, Dict, overload, Union, List
5
5
  from httpx import AsyncClient
6
6
 
7
7
  from e2b import (
@@ -18,6 +18,7 @@ from e2b_code_interpreter.models import (
18
18
  Execution,
19
19
  ExecutionError,
20
20
  Context,
21
+ RunCodeLanguage,
21
22
  Result,
22
23
  aextract_exception,
23
24
  OutputHandlerWithAsync,
@@ -68,41 +69,7 @@ class AsyncSandbox(BaseAsyncSandbox):
68
69
  async def run_code(
69
70
  self,
70
71
  code: str,
71
- language: Union[Literal["python"], None] = None,
72
- on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
73
- on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
74
- on_result: Optional[OutputHandlerWithAsync[Result]] = None,
75
- on_error: Optional[OutputHandlerWithAsync[ExecutionError]] = None,
76
- envs: Optional[Dict[str, str]] = None,
77
- timeout: Optional[float] = None,
78
- request_timeout: Optional[float] = None,
79
- ) -> Execution:
80
- """
81
- Runs the code as Python.
82
-
83
- Specify the `language` or `context` option to run the code as a different language or in a different `Context`.
84
-
85
- You can reference previously defined variables, imports, and functions in the code.
86
-
87
- :param code: Code to execute
88
- :param language: Language to use for code execution. If not defined, the default Python context is used.
89
- :param on_stdout: Callback for stdout messages
90
- :param on_stderr: Callback for stderr messages
91
- :param on_result: Callback for the `Result` object
92
- :param on_error: Callback for the `ExecutionError` object
93
- :param envs: Custom environment variables
94
- :param timeout: Timeout for the code execution in **seconds**
95
- :param request_timeout: Timeout for the request in **seconds**
96
-
97
- :return: `Execution` result object
98
- """
99
- ...
100
-
101
- @overload
102
- async def run_code(
103
- self,
104
- code: str,
105
- language: Optional[str] = None,
72
+ language: Optional[RunCodeLanguage] = None,
106
73
  on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
107
74
  on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
108
75
  on_result: Optional[OutputHandlerWithAsync[Result]] = None,
@@ -236,7 +203,7 @@ class AsyncSandbox(BaseAsyncSandbox):
236
203
  async def create_code_context(
237
204
  self,
238
205
  cwd: Optional[str] = None,
239
- language: Optional[str] = None,
206
+ language: Optional[RunCodeLanguage] = None,
240
207
  request_timeout: Optional[float] = None,
241
208
  ) -> Context:
242
209
  """
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  import httpx
3
3
 
4
- from typing import Optional, Dict, overload, Literal, Union, List
4
+ from typing import Optional, Dict, overload, Union, List
5
5
  from httpx import Client
6
6
  from e2b import Sandbox as BaseSandbox, InvalidArgumentException
7
7
 
@@ -13,6 +13,7 @@ from e2b_code_interpreter.constants import (
13
13
  from e2b_code_interpreter.models import (
14
14
  ExecutionError,
15
15
  Execution,
16
+ RunCodeLanguage,
16
17
  Context,
17
18
  Result,
18
19
  extract_exception,
@@ -65,41 +66,7 @@ class Sandbox(BaseSandbox):
65
66
  def run_code(
66
67
  self,
67
68
  code: str,
68
- language: Union[Literal["python"], None] = None,
69
- on_stdout: Optional[OutputHandler[OutputMessage]] = None,
70
- on_stderr: Optional[OutputHandler[OutputMessage]] = None,
71
- on_result: Optional[OutputHandler[Result]] = None,
72
- on_error: Optional[OutputHandler[ExecutionError]] = None,
73
- envs: Optional[Dict[str, str]] = None,
74
- timeout: Optional[float] = None,
75
- request_timeout: Optional[float] = None,
76
- ) -> Execution:
77
- """
78
- Runs the code as Python.
79
-
80
- Specify the `language` or `context` option to run the code as a different language or in a different `Context`.
81
-
82
- You can reference previously defined variables, imports, and functions in the code.
83
-
84
- :param code: Code to execute
85
- :param language: Language to use for code execution. If not defined, the default Python context is used.
86
- :param on_stdout: Callback for stdout messages
87
- :param on_stderr: Callback for stderr messages
88
- :param on_result: Callback for the `Result` object
89
- :param on_error: Callback for the `ExecutionError` object
90
- :param envs: Custom environment variables
91
- :param timeout: Timeout for the code execution in **seconds**
92
- :param request_timeout: Timeout for the request in **seconds**
93
-
94
- :return: `Execution` result object
95
- """
96
- ...
97
-
98
- @overload
99
- def run_code(
100
- self,
101
- code: str,
102
- language: Optional[str] = None,
69
+ language: Optional[RunCodeLanguage] = None,
103
70
  on_stdout: Optional[OutputHandler[OutputMessage]] = None,
104
71
  on_stderr: Optional[OutputHandler[OutputMessage]] = None,
105
72
  on_result: Optional[OutputHandler[Result]] = None,
@@ -232,7 +199,7 @@ class Sandbox(BaseSandbox):
232
199
  def create_code_context(
233
200
  self,
234
201
  cwd: Optional[str] = None,
235
- language: Optional[str] = None,
202
+ language: Optional[RunCodeLanguage] = None,
236
203
  request_timeout: Optional[float] = None,
237
204
  ) -> Context:
238
205
  """
@@ -6,6 +6,7 @@ from e2b import NotFoundException, TimeoutException, SandboxException
6
6
  from dataclasses import dataclass, field
7
7
  from typing import (
8
8
  List,
9
+ Literal,
9
10
  Optional,
10
11
  Iterable,
11
12
  Dict,
@@ -20,6 +21,11 @@ from httpx import Response
20
21
 
21
22
  from .charts import Chart, _deserialize_chart
22
23
 
24
+ RunCodeLanguage = Union[
25
+ Literal["python", "javascript", "typescript", "r", "java", "bash"],
26
+ str,
27
+ ]
28
+
23
29
  T = TypeVar("T")
24
30
  OutputHandler = Union[Callable[[T], Any],]
25
31
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "e2b-code-interpreter"
3
- version = "2.6.0"
3
+ version = "2.6.2"
4
4
  description = "E2B Code Interpreter - Stateful code execution"
5
5
  authors = ["e2b <hello@e2b.dev>"]
6
6
  license = "MIT"
@@ -14,7 +14,7 @@ python = "^3.10"
14
14
 
15
15
  httpx = ">=0.20.0, <1.0.0"
16
16
  attrs = ">=21.3.0"
17
- e2b = "^2.7.0"
17
+ e2b = "^2.20.3"
18
18
 
19
19
  [tool.poetry.group.dev.dependencies]
20
20
  pytest = "^8.2.0"