abox-code-interpreter 0.1.0__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,10 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 FOUNDRYLABS, INC.
4
+ Copyright (c) 2026 RetailDriver LLC
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ This package is part of AgentBox SDK. It contains software derived from the E2B SDK by FOUNDRYLABS, INC. at commit 5a56c87e9db0e221b138662805af7743e75f1082. See https://github.com/abox-dev/sdk/blob/main/UPSTREAM.md.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: abox-code-interpreter
3
+ Version: 0.1.0
4
+ Summary: AgentBox Code Interpreter - Stateful code execution
5
+ Author: RetailDriver LLC
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ License-File: NOTICE
9
+ Requires-Dist: httpx>=0.20.0,<1.0.0
10
+ Requires-Dist: attrs>=21.3.0
11
+ Requires-Dist: abox-sdk>=0.1.0,<0.2.0
12
+ Requires-Python: >=3.10
13
+ Project-URL: Homepage, https://docs.agentbox.ru/en/sdk/code-interpreter/
14
+ Project-URL: Documentation, https://docs.agentbox.ru/en/sdk/api-reference/python/code-interpreter/
15
+ Project-URL: Repository, https://github.com/abox-dev/sdk/tree/main/packages/code-interpreter-python
16
+ Project-URL: Bug Tracker, https://github.com/abox-dev/sdk/issues
17
+ Description-Content-Type: text/markdown
18
+
19
+ <p align="center"><img src="https://raw.githubusercontent.com/abox-dev/sdk/main/readme-assets/agentbox-logo-email.png" alt="AgentBox" width="240"></p>
20
+
21
+ # `abox-code-interpreter`
22
+
23
+ Stateful Python, JavaScript, and TypeScript execution in an AgentBox sandbox. The distribution is named `abox-code-interpreter`; the Python package is `agentbox_code_interpreter`.
24
+
25
+ ```bash
26
+ pip install abox-code-interpreter
27
+ ```
28
+
29
+ Create an API key using the [API key guide](https://docs.agentbox.ru/en/quickstart/api-key/) and set `AGENTBOX_API_KEY`.
30
+
31
+ ```python
32
+ from agentbox_code_interpreter import Sandbox
33
+
34
+ with Sandbox.create() as sandbox:
35
+ execution = sandbox.run_code("x = 1; x += 1; x")
36
+ print(execution.text)
37
+ ```
38
+
39
+ `AsyncSandbox` provides the equivalent async API. See the [Code Interpreter guide](https://docs.agentbox.ru/en/sdk/code-interpreter/) and [API reference](https://docs.agentbox.ru/en/sdk/api-reference/python/code-interpreter/).
@@ -0,0 +1,21 @@
1
+ <p align="center"><img src="https://raw.githubusercontent.com/abox-dev/sdk/main/readme-assets/agentbox-logo-email.png" alt="AgentBox" width="240"></p>
2
+
3
+ # `abox-code-interpreter`
4
+
5
+ Stateful Python, JavaScript, and TypeScript execution in an AgentBox sandbox. The distribution is named `abox-code-interpreter`; the Python package is `agentbox_code_interpreter`.
6
+
7
+ ```bash
8
+ pip install abox-code-interpreter
9
+ ```
10
+
11
+ Create an API key using the [API key guide](https://docs.agentbox.ru/en/quickstart/api-key/) and set `AGENTBOX_API_KEY`.
12
+
13
+ ```python
14
+ from agentbox_code_interpreter import Sandbox
15
+
16
+ with Sandbox.create() as sandbox:
17
+ execution = sandbox.run_code("x = 1; x += 1; x")
18
+ print(execution.text)
19
+ ```
20
+
21
+ `AsyncSandbox` provides the equivalent async API. See the [Code Interpreter guide](https://docs.agentbox.ru/en/sdk/code-interpreter/) and [API reference](https://docs.agentbox.ru/en/sdk/api-reference/python/code-interpreter/).
@@ -0,0 +1,14 @@
1
+ from agentbox import *
2
+ from .code_interpreter_sync import Sandbox
3
+ from .code_interpreter_async import AsyncSandbox
4
+ from .models import (
5
+ Context,
6
+ Execution,
7
+ ExecutionError,
8
+ Result,
9
+ MIMEType,
10
+ Logs,
11
+ OutputHandler,
12
+ OutputMessage,
13
+ RunCodeLanguage,
14
+ )
@@ -0,0 +1,232 @@
1
+ import enum
2
+ from typing import Any, List, Tuple, Optional, Union
3
+
4
+
5
+ class ChartType(str, enum.Enum):
6
+ """
7
+ Chart types
8
+ """
9
+
10
+ LINE = "line"
11
+ SCATTER = "scatter"
12
+ BAR = "bar"
13
+ PIE = "pie"
14
+ BOX_AND_WHISKER = "box_and_whisker"
15
+ SUPERCHART = "superchart"
16
+ UNKNOWN = "unknown"
17
+
18
+
19
+ class ScaleType(str, enum.Enum):
20
+ """
21
+ Ax scale types
22
+ """
23
+
24
+ LINEAR = "linear"
25
+ DATETIME = "datetime"
26
+ CATEGORICAL = "categorical"
27
+ LOG = "log"
28
+ SYMLOG = "symlog"
29
+ LOGIT = "logit"
30
+ FUNCTION = "function"
31
+ FUNCTIONLOG = "functionlog"
32
+ ASINH = "asinh"
33
+ UNKNOWN = "unknown"
34
+
35
+
36
+ class Chart:
37
+ """
38
+ Extracted data from a chart. It's useful for building an interactive charts or custom visualizations.
39
+ """
40
+
41
+ type: ChartType
42
+ title: str
43
+
44
+ elements: List[Any]
45
+
46
+ def __init__(self, **kwargs):
47
+ self._raw_data = kwargs
48
+ self.type = ChartType(kwargs["type"] or ChartType.UNKNOWN)
49
+ self.title = kwargs["title"]
50
+ self.elements = kwargs["elements"]
51
+
52
+ def to_dict(self) -> dict:
53
+ return self._raw_data
54
+
55
+
56
+ class Chart2D(Chart):
57
+ x_label: Optional[str]
58
+ y_label: Optional[str]
59
+ x_unit: Optional[str]
60
+ y_unit: Optional[str]
61
+
62
+ def __init__(self, **kwargs):
63
+ super().__init__(**kwargs)
64
+ self.x_label = kwargs["x_label"]
65
+ self.y_label = kwargs["y_label"]
66
+ self.x_unit = kwargs["x_unit"]
67
+ self.y_unit = kwargs["y_unit"]
68
+
69
+
70
+ class PointData:
71
+ label: str
72
+ points: List[Tuple[Union[str, float], Union[str, float]]]
73
+
74
+ def __init__(self, **kwargs):
75
+ self.label = kwargs["label"]
76
+ self.points = [(x, y) for x, y in kwargs["points"]]
77
+
78
+
79
+ class PointChart(Chart2D):
80
+ x_ticks: List[Union[str, float]]
81
+ x_tick_labels: List[str]
82
+ x_scale: ScaleType
83
+
84
+ y_ticks: List[Union[str, float]]
85
+ y_tick_labels: List[str]
86
+ y_scale: ScaleType
87
+
88
+ elements: List[PointData]
89
+
90
+ def __init__(self, **kwargs):
91
+ super().__init__(**kwargs)
92
+ self.x_label = kwargs["x_label"]
93
+
94
+ try:
95
+ self.x_scale = ScaleType(kwargs.get("x_scale"))
96
+ except ValueError:
97
+ self.x_scale = ScaleType.UNKNOWN
98
+
99
+ self.x_ticks = kwargs["x_ticks"]
100
+ self.x_tick_labels = kwargs["x_tick_labels"]
101
+
102
+ self.y_label = kwargs["y_label"]
103
+
104
+ try:
105
+ self.y_scale = ScaleType(kwargs.get("y_scale"))
106
+ except ValueError:
107
+ self.y_scale = ScaleType.UNKNOWN
108
+
109
+ self.y_ticks = kwargs["y_ticks"]
110
+ self.y_tick_labels = kwargs["y_tick_labels"]
111
+
112
+ self.elements = [PointData(**d) for d in kwargs["elements"]]
113
+
114
+
115
+ class LineChart(PointChart):
116
+ type = ChartType.LINE
117
+
118
+
119
+ class ScatterChart(PointChart):
120
+ type = ChartType.SCATTER
121
+
122
+
123
+ class BarData:
124
+ label: str
125
+ group: str
126
+ value: str
127
+
128
+ def __init__(self, **kwargs):
129
+ self.label = kwargs["label"]
130
+ self.value = kwargs["value"]
131
+ self.group = kwargs["group"]
132
+
133
+
134
+ class BarChart(Chart2D):
135
+ type = ChartType.BAR
136
+
137
+ elements: List[BarData]
138
+
139
+ def __init__(self, **kwargs):
140
+ super().__init__(**kwargs)
141
+ self.elements = [BarData(**d) for d in kwargs["elements"]]
142
+
143
+
144
+ class PieData:
145
+ label: str
146
+ angle: float
147
+ radius: float
148
+
149
+ def __init__(self, **kwargs):
150
+ self.label = kwargs["label"]
151
+ self.angle = kwargs["angle"]
152
+ self.radius = kwargs["radius"]
153
+
154
+
155
+ class PieChart(Chart):
156
+ type = ChartType.PIE
157
+
158
+ elements: List[PieData]
159
+
160
+ def __init__(self, **kwargs):
161
+ super().__init__(**kwargs)
162
+ self.elements = [PieData(**d) for d in kwargs["elements"]]
163
+
164
+
165
+ class BoxAndWhiskerData:
166
+ label: str
167
+ min: float
168
+ first_quartile: float
169
+ median: float
170
+ third_quartile: float
171
+ max: float
172
+ outliers: List[float]
173
+
174
+ def __init__(self, **kwargs):
175
+ self.label = kwargs["label"]
176
+ self.min = kwargs["min"]
177
+ self.first_quartile = kwargs["first_quartile"]
178
+ self.median = kwargs["median"]
179
+ self.third_quartile = kwargs["third_quartile"]
180
+ self.max = kwargs["max"]
181
+ self.outliers = kwargs.get("outliers") or []
182
+
183
+
184
+ class BoxAndWhiskerChart(Chart2D):
185
+ type = ChartType.BOX_AND_WHISKER
186
+
187
+ elements: List[BoxAndWhiskerData]
188
+
189
+ def __init__(self, **kwargs):
190
+ super().__init__(**kwargs)
191
+ self.elements = [BoxAndWhiskerData(**d) for d in kwargs["elements"]]
192
+
193
+
194
+ class SuperChart(Chart):
195
+ type = ChartType.SUPERCHART
196
+
197
+ elements: List[Chart]
198
+
199
+ def __init__(self, **kwargs):
200
+ super().__init__(**kwargs)
201
+ self.elements = []
202
+ for raw_chart in kwargs["elements"]:
203
+ chart = _deserialize_chart(raw_chart)
204
+ if chart is not None:
205
+ self.elements.append(chart)
206
+
207
+
208
+ ChartTypes = Union[
209
+ Chart, LineChart, ScatterChart, BarChart, PieChart, BoxAndWhiskerChart, SuperChart
210
+ ]
211
+
212
+
213
+ def _deserialize_chart(data: Optional[dict]) -> Optional[ChartTypes]:
214
+ if not data:
215
+ return None
216
+
217
+ if data["type"] == ChartType.LINE:
218
+ chart = LineChart(**data)
219
+ elif data["type"] == ChartType.SCATTER:
220
+ chart = ScatterChart(**data)
221
+ elif data["type"] == ChartType.BAR:
222
+ chart = BarChart(**data)
223
+ elif data["type"] == ChartType.PIE:
224
+ chart = PieChart(**data)
225
+ elif data["type"] == ChartType.BOX_AND_WHISKER:
226
+ chart = BoxAndWhiskerChart(**data)
227
+ elif data["type"] == ChartType.SUPERCHART:
228
+ chart = SuperChart(**data)
229
+ else:
230
+ chart = Chart(**data)
231
+
232
+ return chart