Skip to content

Commit 9aefef7

Browse files
authored
Merge pull request #25 from e2b-dev/beta
Use the new SDK V1 Beta
2 parents a9e1639 + 76d5b44 commit 9aefef7

File tree

142 files changed

+9621
-6182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+9621
-6182
lines changed

.changeset/pink-weeks-call.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@e2b/code-interpreter-python': major
3+
'@e2b/code-interpreter': major
4+
---
5+
6+
New improved SDK

.github/workflows/js_tests.yml

+25-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
contents: read
1111

1212
jobs:
13-
publish:
13+
test:
1414
defaults:
1515
run:
1616
working-directory: ./js
@@ -21,10 +21,10 @@ jobs:
2121
uses: actions/checkout@v3
2222

2323
- name: Install pnpm
24-
uses: pnpm/action-setup@v2
24+
uses: pnpm/action-setup@v3
2525
id: pnpm-install
2626
with:
27-
version: 8
27+
version: 9.5
2828

2929
- name: Setup Node
3030
uses: actions/setup-node@v3
@@ -45,7 +45,27 @@ jobs:
4545
- name: Test build
4646
run: pnpm build
4747

48-
- name: Run node tests
49-
run: pnpm run test
48+
- name: Run Node tests
49+
run: pnpm test
50+
env:
51+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
52+
53+
- name: Install Bun
54+
uses: oven-sh/setup-bun@v2
55+
with:
56+
version: 1.1.x
57+
#
58+
# - name: Run Bun tests
59+
# run: pnpm test:bun
60+
# env:
61+
# E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
62+
63+
- name: Install Deno
64+
uses: denoland/setup-deno@v1
65+
with:
66+
deno-version: v1.x
67+
68+
- name: Run Deno tests
69+
run: pnpm test:deno
5070
env:
5171
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}

.github/workflows/pr.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Python package
1+
name: Test package
22

33
on:
44
push:
@@ -11,6 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
outputs:
1313
python: ${{ steps.filter.outputs.python }}
14+
js: ${{ steps.filter.outputs.js }}
1415
steps:
1516
- name: Checkout repository
1617
uses: actions/checkout@v3

.github/workflows/python_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ jobs:
4040
run: poetry build
4141

4242
- name: Run tests
43-
run: poetry run pytest --verbose -x
43+
run: poetry run pytest -n 4 --verbose -x
4444
env:
4545
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}

.github/workflows/release.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
uses: actions/checkout@v3
2222

2323
- name: Install pnpm
24-
uses: pnpm/action-setup@v2
24+
uses: pnpm/action-setup@v3
2525
id: pnpm-install
2626
with:
27-
version: 8
27+
version: 9.5
2828

2929
- name: Setup Node
3030
uses: actions/setup-node@v3
@@ -109,7 +109,7 @@ jobs:
109109
- name: Set up Python
110110
uses: actions/setup-python@v4
111111
with:
112-
python-version: "3.10"
112+
python-version: "3.8"
113113

114114
- name: Install and configure Poetry
115115
uses: snok/install-poetry@v1
@@ -119,12 +119,14 @@ jobs:
119119
virtualenvs-in-project: true
120120
installer-parallel: true
121121

122-
- uses: pnpm/action-setup@v2
122+
- uses: pnpm/action-setup@v3
123+
with:
124+
version: 9.5
123125

124-
- name: Setup Node.js 20
126+
- name: Setup Node.js 18
125127
uses: actions/setup-node@v3
126128
with:
127-
node-version: 20
129+
node-version: '18.x'
128130
cache: pnpm
129131

130132
- name: Configure pnpm

.github/workflows/release_candidates.yml

+22-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ jobs:
1919

2020
- uses: pnpm/action-setup@v3
2121
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
22+
with:
23+
version: 9.5
2224

23-
- name: Setup Node.js 20
25+
- name: Setup Node.js 18
2426
uses: actions/setup-node@v4
2527
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
2628
with:
27-
node-version: 20
29+
node-version: '18.x'
2830
registry-url: https://registry.npmjs.org
2931
cache: pnpm
3032

@@ -38,6 +40,14 @@ jobs:
3840
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
3941
run: pnpm install --frozen-lockfile
4042

43+
- name: Test JS SDK
44+
working-directory: js
45+
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
46+
run: |
47+
pnpm run test
48+
env:
49+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
50+
4151
- name: Release JS Candidate
4252
working-directory: js
4353
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
@@ -51,7 +61,7 @@ jobs:
5161
uses: actions/setup-python@v4
5262
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
5363
with:
54-
python-version: "3.10"
64+
python-version: "3.8"
5565

5666
- name: Install and configure Poetry
5767
uses: snok/install-poetry@v1
@@ -62,6 +72,15 @@ jobs:
6272
virtualenvs-in-project: true
6373
installer-parallel: true
6474

75+
- name: Test Python SDK
76+
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
77+
working-directory: python
78+
run: |
79+
poetry install
80+
poetry run pytest -n 4 --verbose -x
81+
env:
82+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
83+
6584
- name: Release Candidate
6685
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
6786
working-directory: python

.github/workflows/template.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- 'template/**'
77
- '.github/workflows/template.yml'
88
branches:
9-
- beta
9+
- main
1010

1111
permissions:
1212
contents: read
@@ -36,8 +36,8 @@ jobs:
3636
run: |
3737
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest || true
3838
docker buildx build \
39-
--file e2b.Dockerfile \
40-
--platform linux/amd64,linux/arm64 \
39+
--file Dockerfile \
40+
--platform linux/amd64 \
4141
--push \
4242
--tag ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest .
4343
@@ -47,4 +47,4 @@ jobs:
4747
- name: Build e2b
4848
run: e2b template build
4949
env:
50-
E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }}
50+
E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }}

.npmrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ enable-pre-post-scripts=true
22
auto-install-peers=true
33
exclude-links-from-lockfile=true
44
prefer-workspace-packages=false
5-
link-workspace-packages=false
5+
link-workspace-packages=false
6+
engine-strict=true

.prettierignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.next/
2+
3+
# imporatant to keep // $HighlightLine comments at the end of the line
4+
apps/web/src/code/
5+
6+
7+
**/*.mdx
8+
**/code/**/*

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false,
4+
"trailingComma": "es5"
5+
}

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
start-template-server:
2+
docker run --rm -e E2B_LOCAL=true -p 49999:49999 -it $$(docker build -q ./template -f ./template/test.Dockerfile)
3+
4+
kill-template-server:
5+
docker kill $(shell docker ps --filter expose=49999 --format {{.ID}})

README.md

+47-55
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,71 @@
1-
# Code Interpreter SDK
2-
E2B's [Code Interpreter SDK](https://github.com/e2b-dev/code-interpreter) allows you to add code interpreting capabilities to your AI apps.
3-
4-
The code interpreter runs inside the [E2B Sandbox](https://github.com/e2b-dev/e2b) - an open-source secure sandbox made for running untrusted AI-generated code and AI agents.
5-
- ✅ Works with any LLM and AI framework
6-
- ✅ Supports streaming content like charts and stdout, stderr
7-
- ✅ Python & JS SDK
8-
- ✅ Runs on serverless and edge functions
9-
- ✅ Runs AI-generated code in secure sandboxed environments
10-
- ✅ 100% open source (including [infrastructure](https://github.com/e2b-dev/infra))
11-
12-
Follow E2B on [X (Twitter)](https://twitter.com/e2b_dev).
13-
14-
## 💻 Supported language runtimes
15-
- ✅ Python
16-
- [(Beta)](https://e2b.dev/docs/guide/beta-code-interpreter-language-runtimes) JavaScript, R, Java
17-
18-
## 📖 Documentation
19-
- [e2b.dev/docs/code-interpreter](https://e2b.dev/docs/code-interpreter/installation)
20-
21-
## 🚀 Quickstart
1+
<p align="center">
2+
<img width="100" src="/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+
<a href="https://www.npmjs.com/package/e2b">
11+
<img alt="Last 1 month downloads for the JavaScript SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
12+
style="color:transparent;width:auto;height:100%" src="https://img.shields.io/npm/dm/e2b?label=NPM%20Downloads">
13+
</a>
14+
</h4>
15+
16+
<!---
17+
<img width="100%" src="/readme-assets/preview.png" alt="Cover image">
18+
--->
19+
## What is E2B?
20+
[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).
21+
22+
## Run your first Sandbox
2223

2324
### 1. Install SDK
2425

25-
JavaScript/TypeScript
26+
JavaScript / TypeScript
2627
```
2728
npm i @e2b/code-interpreter
2829
```
2930

3031
Python
3132
```
32-
pip install e2b_code_interpreter
33+
pip install e2b-code-interpreter
34+
```
35+
36+
### 2. Get your E2B API key
37+
1. Sign up to E2B [here](https://e2b.dev).
38+
2. Get your API key [here](https://e2b.dev/dashboard?tab=keys).
39+
3. Set environment variable with your API key
3340
```
41+
E2B_API_KEY=e2b_***
42+
```
3443

35-
### 2. Execute code with code interpreter inside sandbox
44+
### 3. Execute code with code interpreter inside Sandbox
3645

37-
**JavaScript**
46+
JavaScript / TypeScript
3847
```ts
39-
import { CodeInterpreter } from '@e2b/code-interpreter'
48+
import { Sandbox } from '@e2b/code-interpreter'
4049

41-
const sandbox = await CodeInterpreter.create()
42-
await sandbox.notebook.execCell('x = 1')
50+
const sandbox = await Sandbox.create()
51+
await sbx.runCode()('x = 1')
4352

44-
const execution = await sandbox.notebook.execCell('x+=1; x')
53+
const execution = await sbx.runCode()('x+=1; x')
4554
console.log(execution.text) // outputs 2
46-
47-
await sandbox.close()
4855
```
4956

50-
**Python**
57+
Python
5158
```py
52-
from e2b_code_interpreter import CodeInterpreter
59+
from e2b_code_interpreter import Sandbox
5360

54-
with CodeInterpreter() as sandbox:
55-
sandbox.notebook.exec_cell("x = 1")
56-
57-
execution = sandbox.notebook.exec_cell("x+=1; x")
61+
with Sandbox() as sandbox:
62+
sandbox.run_code()("x = 1")
63+
execution = sandbox.run_code()("x+=1; x")
5864
print(execution.text) # outputs 2
5965
```
6066

61-
### 3. Hello World guide
62-
Dive depeer and 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 connect code interpreter LLMs.
63-
64-
## 📖 Cookbook examples
65-
66-
**Hello World**
67-
- [JavaScript/TypeScript](https://e2b.dev/docs/hello-world/js)
68-
- [Python](https://e2b.dev/docs/hello-world/py)
69-
70-
**LLM Providers**
71-
- 🪸 [Claude with code intepreter](https://github.com/e2b-dev/e2b-cookbook/blob/main/examples/claude-code-interpreter-python/claude_code_interpreter.ipynb)
72-
- 🦙 [Llama 3 with code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/llama-3-code-interpreter-python)
73-
- [Mixtral with code interpreter and chat UI](https://github.com/e2b-dev/e2b-cookbook/tree/main/templates/mixtral-8x7b-code-interpreter-nextjs)
74-
75-
**AI Frameworks**
76-
- 🦜⛓️ [LangChain with code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/langchain-python)
77-
- 🦜🕸️ [LangGraph with code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/langgraph-python)
78-
- [Autogen with secure sandboxed code interpreter](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/e2b_autogen)
67+
### 4. Check docs
68+
Visit [E2B documentation](https://e2b.dev/docs).
7969

70+
### 5. E2B cookbook
71+
Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks.

js/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deno.lock

0 commit comments

Comments
 (0)