e2b-code-interpreter 1.0.0__tar.gz → 1.0.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.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.1
2
+ Name: e2b-code-interpreter
3
+ Version: 1.0.2
4
+ Summary: E2B Code Interpreter - Stateful code execution
5
+ Home-page: https://e2b.dev/
6
+ License: Apache-2.0
7
+ Author: e2b
8
+ Author-email: hello@e2b.dev
9
+ Requires-Python: >=3.8,<4.0
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Dist: attrs (>=21.3.0)
18
+ Requires-Dist: e2b (>=1.0.4,<2.0.0)
19
+ Requires-Dist: httpx (>=0.20.0,<0.28.0)
20
+ Project-URL: Bug Tracker, https://github.com/e2b-dev/code-interpreter/issues
21
+ Project-URL: Repository, https://github.com/e2b-dev/code-interpreter/tree/main/python
22
+ Description-Content-Type: text/markdown
23
+
24
+ <p align="center">
25
+ <img width="100" src="https://raw.githubusercontent.com/e2b-dev/E2B/refs/heads/main/readme-assets/logo-circle.png" alt="e2b logo">
26
+ </p>
27
+
28
+ <h4 align="center">
29
+ <a href="https://pypi.org/project/e2b/">
30
+ <img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
31
+ style="color:transparent;width:auto;height:100%" src="https://img.shields.io/pypi/dm/e2b?label=PyPI%20Downloads">
32
+ </a>
33
+ </h4>
34
+
35
+ <!---
36
+ <img width="100%" src="/readme-assets/preview.png" alt="Cover image">
37
+ --->
38
+ ## What is E2B?
39
+ [E2B](https://www.e2b.dev/) is an open-source infrastructure that allows you run to AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our [JavaScript SDK](https://www.npmjs.com/package/@e2b/code-interpreter) or [Python SDK](https://pypi.org/project/e2b_code_interpreter).
40
+
41
+ ## Run your first Sandbox
42
+
43
+ ### 1. Install SDK
44
+
45
+ ```
46
+ pip install e2b-code-interpreter
47
+ ```
48
+
49
+ ### 2. Get your E2B API key
50
+ 1. Sign up to E2B [here](https://e2b.dev).
51
+ 2. Get your API key [here](https://e2b.dev/dashboard?tab=keys).
52
+ 3. Set environment variable with your API key.
53
+ ```
54
+ E2B_API_KEY=e2b_***
55
+ ```
56
+
57
+ ### 3. Execute code with code interpreter inside Sandbox
58
+
59
+ ```py
60
+ from e2b_code_interpreter import Sandbox
61
+
62
+ with Sandbox() as sandbox:
63
+ sandbox.run_code("x = 1")
64
+ execution = sandbox.run_code("x+=1; x")
65
+ print(execution.text) # outputs 2
66
+ ```
67
+
68
+ ### 4. Check docs
69
+ Visit [E2B documentation](https://e2b.dev/docs).
70
+
71
+ ### 5. E2B cookbook
72
+ Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks.
73
+
@@ -0,0 +1,49 @@
1
+ <p align="center">
2
+ <img width="100" src="https://raw.githubusercontent.com/e2b-dev/E2B/refs/heads/main/readme-assets/logo-circle.png" alt="e2b logo">
3
+ </p>
4
+
5
+ <h4 align="center">
6
+ <a href="https://pypi.org/project/e2b/">
7
+ <img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
8
+ style="color:transparent;width:auto;height:100%" src="https://img.shields.io/pypi/dm/e2b?label=PyPI%20Downloads">
9
+ </a>
10
+ </h4>
11
+
12
+ <!---
13
+ <img width="100%" src="/readme-assets/preview.png" alt="Cover image">
14
+ --->
15
+ ## What is E2B?
16
+ [E2B](https://www.e2b.dev/) is an open-source infrastructure that allows you run to AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our [JavaScript SDK](https://www.npmjs.com/package/@e2b/code-interpreter) or [Python SDK](https://pypi.org/project/e2b_code_interpreter).
17
+
18
+ ## Run your first Sandbox
19
+
20
+ ### 1. Install SDK
21
+
22
+ ```
23
+ pip install e2b-code-interpreter
24
+ ```
25
+
26
+ ### 2. Get your E2B API key
27
+ 1. Sign up to E2B [here](https://e2b.dev).
28
+ 2. Get your API key [here](https://e2b.dev/dashboard?tab=keys).
29
+ 3. Set environment variable with your API key.
30
+ ```
31
+ E2B_API_KEY=e2b_***
32
+ ```
33
+
34
+ ### 3. Execute code with code interpreter inside Sandbox
35
+
36
+ ```py
37
+ from e2b_code_interpreter import Sandbox
38
+
39
+ with Sandbox() as sandbox:
40
+ sandbox.run_code("x = 1")
41
+ execution = sandbox.run_code("x+=1; x")
42
+ print(execution.text) # outputs 2
43
+ ```
44
+
45
+ ### 4. Check docs
46
+ Visit [E2B documentation](https://e2b.dev/docs).
47
+
48
+ ### 5. E2B cookbook
49
+ Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks.
@@ -165,6 +165,7 @@ class BoxAndWhiskerData:
165
165
  median: float
166
166
  third_quartile: float
167
167
  max: float
168
+ outliers: List[float]
168
169
 
169
170
  def __init__(self, **kwargs):
170
171
  self.label = kwargs["label"]
@@ -173,6 +174,7 @@ class BoxAndWhiskerData:
173
174
  self.median = kwargs["median"]
174
175
  self.third_quartile = kwargs["third_quartile"]
175
176
  self.max = kwargs["max"]
177
+ self.outliers = kwargs.get("outliers") or []
176
178
 
177
179
 
178
180
  class BoxAndWhiskerChart(Chart2D):
@@ -1,12 +1,12 @@
1
1
  [tool.poetry]
2
2
  name = "e2b-code-interpreter"
3
- version = "1.0.0"
3
+ version = "1.0.2"
4
4
  description = "E2B Code Interpreter - Stateful code execution"
5
5
  authors = ["e2b <hello@e2b.dev>"]
6
6
  license = "Apache-2.0"
7
7
  readme = "README.md"
8
8
  homepage = "https://e2b.dev/"
9
- repository = "https://github.com/e2b-dev/e2b-code-interpreter/tree/python"
9
+ repository = "https://github.com/e2b-dev/code-interpreter/tree/main/python"
10
10
  packages = [{ include = "e2b_code_interpreter" }]
11
11
 
12
12
  [tool.poetry.dependencies]
@@ -14,15 +14,16 @@ python = "^3.8"
14
14
 
15
15
  httpx = ">=0.20.0,<0.28.0"
16
16
  attrs = ">=21.3.0"
17
- e2b = "^1.0.0"
17
+ e2b = "^1.0.4"
18
18
 
19
19
  [tool.poetry.group.dev.dependencies]
20
- black = "^24.3.0"
21
20
  pytest = "^7.4.0"
22
21
  python-dotenv = "^1.0.0"
23
22
  pytest-dotenv = "^0.5.2"
24
23
  pytest-asyncio = "^0.23.7"
25
24
  pytest-xdist = "^3.6.1"
25
+ black = "23.12.1"
26
+ pydoc-markdown = "^4.8.2"
26
27
 
27
28
  [build-system]
28
29
  requires = ["poetry-core"]
@@ -1,150 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: e2b-code-interpreter
3
- Version: 1.0.0
4
- Summary: E2B Code Interpreter - Stateful code execution
5
- Home-page: https://e2b.dev/
6
- License: Apache-2.0
7
- Author: e2b
8
- Author-email: hello@e2b.dev
9
- Requires-Python: >=3.8,<4.0
10
- Classifier: License :: OSI Approved :: Apache Software License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Requires-Dist: attrs (>=21.3.0)
18
- Requires-Dist: e2b (>=1.0.0,<2.0.0)
19
- Requires-Dist: httpx (>=0.20.0,<0.28.0)
20
- Project-URL: Bug Tracker, https://github.com/e2b-dev/code-interpreter/issues
21
- Project-URL: Repository, https://github.com/e2b-dev/e2b-code-interpreter/tree/python
22
- Description-Content-Type: text/markdown
23
-
24
- <p align="center">
25
- <img width="100" src="/readme-assets/logo-circle.png" alt="e2b logo">
26
- </p>
27
-
28
-
29
- <h1 align="center">
30
- Code interpreter extension for Python
31
- </h1>
32
-
33
- <h4 align="center">
34
- <a href="https://pypi.org/project/e2b/">
35
- <img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
36
- style="color:transparent;width:auto;height:100%" src="https://img.shields.io/pypi/dm/e2b?label=PyPI%20Downloads">
37
- </a>
38
- <a href="https://www.npmjs.com/package/e2b">
39
- <img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
40
- style="color:transparent;width:auto;height:100%" src="https://img.shields.io/npm/dm/e2b?label=NPM%20Downloads">
41
- </a>
42
- </h4>
43
-
44
- The repository contains a template and modules for the code interpreter sandbox. It is based on the Jupyter server and implements the Jupyter Kernel messaging protocol. This allows for sharing context between code executions and improves support for plotting charts and other display-able data.
45
-
46
- ## Key Features
47
-
48
- - **Stateful Execution**: Unlike traditional sandboxes that treat each code execution independently, this package maintains context across executions.
49
- - **Displaying Charts & Data**: Implements parts of the [Jupyter Kernel messaging protocol](https://jupyter-client.readthedocs.io/en/latest/messaging.html), which support for interactive features like plotting charts, rendering DataFrames, etc.
50
-
51
- ## Installation
52
-
53
- ```sh
54
- pip install e2b-code-interpreter
55
- ```
56
-
57
- ## Examples
58
-
59
- ### Minimal example with the sharing context
60
-
61
- ```python
62
- from e2b_code_interpreter import Sandbox
63
-
64
- with Sandbox() as sandbox:
65
- sandbox.run_code()("x = 1")
66
-
67
- execution = sandbox.run_code()("x+=1; x")
68
- print(execution.text) # outputs 2
69
- ```
70
-
71
- ### Get charts and any display-able data
72
-
73
- ```python
74
- import base64
75
- import io
76
-
77
- from matplotlib import image as mpimg, pyplot as plt
78
-
79
- from e2b_code_interpreter import Sandbox
80
-
81
- code = """
82
- import matplotlib.pyplot as plt
83
- import numpy as np
84
-
85
- x = np.linspace(0, 20, 100)
86
- y = np.sin(x)
87
-
88
- plt.plot(x, y)
89
- plt.show()
90
- """
91
-
92
- with Sandbox() as sandbox:
93
- # you can install dependencies in "jupyter notebook style"
94
- sandbox.run_code("!pip install matplotlib")
95
-
96
- # plot random chart
97
- execution = sandbox.run_code(code)
98
-
99
- # there's your image
100
- image = execution.results[0].png
101
-
102
- # example how to show the image / prove it works
103
- i = base64.b64decode(image)
104
- i = io.BytesIO(i)
105
- i = mpimg.imread(i, format='PNG')
106
-
107
- plt.imshow(i, interpolation='nearest')
108
- plt.show()
109
- ```
110
-
111
- ### Streaming code output
112
-
113
- ```python
114
- from e2b_code_interpreter import Sandbox
115
-
116
- code = """
117
- import time
118
- import pandas as pd
119
-
120
- print("hello")
121
- time.sleep(3)
122
- data = pd.DataFrame(data=[[1, 2], [3, 4]], columns=["A", "B"])
123
- display(data.head(10))
124
- time.sleep(3)
125
- print("world")
126
- """
127
-
128
- with Sandbox() as sandbox:
129
- sandbox.run_code(code, on_stdout=print, on_stderr=print, on_result=(lambda result: print(result.text)))
130
- ```
131
-
132
- ### More resources
133
- - Check out the [JavaScript/TypeScript](https://e2b.dev/docs/hello-world/js) and [Python](https://e2b.dev/docs/hello-world/py) "Hello World" guides to learn how to use our SDK.
134
-
135
- - See [E2B documentation](https://e2b.dev/docs) to get started.
136
-
137
- - Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks.
138
-
139
- ___
140
-
141
- <div align='center'>
142
- <!-- <a href="https://e2b.dev/docs" target="_blank">
143
- <img src="https://img.shields.io/badge/docs-%2300acee.svg?color=143D52&style=for-the-badge&logo=x&logoColor=white" alt=docs style="margin-bottom: 5px;"/></a> -->
144
- <a href="https://twitter.com/e2b_dev" target="_blank">
145
- <img src="https://img.shields.io/badge/x (twitter)-%2300acee.svg?color=000000&style=for-the-badge&logo=x&logoColor=white" alt=linkedin style="margin-bottom: 5px;"/></a>
146
- <a href="https://discord.com/invite/U7KEcGErtQ" target="_blank">
147
- <img src="https://img.shields.io/badge/discord -%2300acee.svg?color=143D52&style=for-the-badge&logo=discord&logoColor=white" alt=discord style="margin-bottom: 5px;"/></a>
148
- <a href="https://www.linkedin.com/company/e2b-dev/" target="_blank">
149
- <img src="https://img.shields.io/badge/linkedin-%2300acee.svg?color=000000&style=for-the-badge&logo=linkedin&logoColor=white" alt=linkedin style="margin-bottom: 5px;"/></a>
150
- </div align='center'>
@@ -1,127 +0,0 @@
1
- <p align="center">
2
- <img width="100" src="/readme-assets/logo-circle.png" alt="e2b logo">
3
- </p>
4
-
5
-
6
- <h1 align="center">
7
- Code interpreter extension for Python
8
- </h1>
9
-
10
- <h4 align="center">
11
- <a href="https://pypi.org/project/e2b/">
12
- <img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
13
- style="color:transparent;width:auto;height:100%" src="https://img.shields.io/pypi/dm/e2b?label=PyPI%20Downloads">
14
- </a>
15
- <a href="https://www.npmjs.com/package/e2b">
16
- <img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
17
- style="color:transparent;width:auto;height:100%" src="https://img.shields.io/npm/dm/e2b?label=NPM%20Downloads">
18
- </a>
19
- </h4>
20
-
21
- The repository contains a template and modules for the code interpreter sandbox. It is based on the Jupyter server and implements the Jupyter Kernel messaging protocol. This allows for sharing context between code executions and improves support for plotting charts and other display-able data.
22
-
23
- ## Key Features
24
-
25
- - **Stateful Execution**: Unlike traditional sandboxes that treat each code execution independently, this package maintains context across executions.
26
- - **Displaying Charts & Data**: Implements parts of the [Jupyter Kernel messaging protocol](https://jupyter-client.readthedocs.io/en/latest/messaging.html), which support for interactive features like plotting charts, rendering DataFrames, etc.
27
-
28
- ## Installation
29
-
30
- ```sh
31
- pip install e2b-code-interpreter
32
- ```
33
-
34
- ## Examples
35
-
36
- ### Minimal example with the sharing context
37
-
38
- ```python
39
- from e2b_code_interpreter import Sandbox
40
-
41
- with Sandbox() as sandbox:
42
- sandbox.run_code()("x = 1")
43
-
44
- execution = sandbox.run_code()("x+=1; x")
45
- print(execution.text) # outputs 2
46
- ```
47
-
48
- ### Get charts and any display-able data
49
-
50
- ```python
51
- import base64
52
- import io
53
-
54
- from matplotlib import image as mpimg, pyplot as plt
55
-
56
- from e2b_code_interpreter import Sandbox
57
-
58
- code = """
59
- import matplotlib.pyplot as plt
60
- import numpy as np
61
-
62
- x = np.linspace(0, 20, 100)
63
- y = np.sin(x)
64
-
65
- plt.plot(x, y)
66
- plt.show()
67
- """
68
-
69
- with Sandbox() as sandbox:
70
- # you can install dependencies in "jupyter notebook style"
71
- sandbox.run_code("!pip install matplotlib")
72
-
73
- # plot random chart
74
- execution = sandbox.run_code(code)
75
-
76
- # there's your image
77
- image = execution.results[0].png
78
-
79
- # example how to show the image / prove it works
80
- i = base64.b64decode(image)
81
- i = io.BytesIO(i)
82
- i = mpimg.imread(i, format='PNG')
83
-
84
- plt.imshow(i, interpolation='nearest')
85
- plt.show()
86
- ```
87
-
88
- ### Streaming code output
89
-
90
- ```python
91
- from e2b_code_interpreter import Sandbox
92
-
93
- code = """
94
- import time
95
- import pandas as pd
96
-
97
- print("hello")
98
- time.sleep(3)
99
- data = pd.DataFrame(data=[[1, 2], [3, 4]], columns=["A", "B"])
100
- display(data.head(10))
101
- time.sleep(3)
102
- print("world")
103
- """
104
-
105
- with Sandbox() as sandbox:
106
- sandbox.run_code(code, on_stdout=print, on_stderr=print, on_result=(lambda result: print(result.text)))
107
- ```
108
-
109
- ### More resources
110
- - Check out the [JavaScript/TypeScript](https://e2b.dev/docs/hello-world/js) and [Python](https://e2b.dev/docs/hello-world/py) "Hello World" guides to learn how to use our SDK.
111
-
112
- - See [E2B documentation](https://e2b.dev/docs) to get started.
113
-
114
- - Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks.
115
-
116
- ___
117
-
118
- <div align='center'>
119
- <!-- <a href="https://e2b.dev/docs" target="_blank">
120
- <img src="https://img.shields.io/badge/docs-%2300acee.svg?color=143D52&style=for-the-badge&logo=x&logoColor=white" alt=docs style="margin-bottom: 5px;"/></a> -->
121
- <a href="https://twitter.com/e2b_dev" target="_blank">
122
- <img src="https://img.shields.io/badge/x (twitter)-%2300acee.svg?color=000000&style=for-the-badge&logo=x&logoColor=white" alt=linkedin style="margin-bottom: 5px;"/></a>
123
- <a href="https://discord.com/invite/U7KEcGErtQ" target="_blank">
124
- <img src="https://img.shields.io/badge/discord -%2300acee.svg?color=143D52&style=for-the-badge&logo=discord&logoColor=white" alt=discord style="margin-bottom: 5px;"/></a>
125
- <a href="https://www.linkedin.com/company/e2b-dev/" target="_blank">
126
- <img src="https://img.shields.io/badge/linkedin-%2300acee.svg?color=000000&style=for-the-badge&logo=linkedin&logoColor=white" alt=linkedin style="margin-bottom: 5px;"/></a>
127
- </div align='center'>