Skip to content

Commit 73ef847

Browse files
authored
Update README.md
1 parent 5a0afa7 commit 73ef847

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

template/README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
# Code Interpreter template
1+
# Using custom sandbox with Code Interpreter SDK
22

3-
This template runs a Jupyter server with a Python kernel. The jupyter server is started in `start_cmd`, this way the server will be already running when the sandbox is started.
3+
If you want to customize the Code Interprerter sandbox (e.g.: add a preinstlled package) you can do that by using a [custom sandbox template](https://e2b.dev/docs/sandbox/templates/overview).
44

5-
## Customization
5+
1. Create custom sandbox by following [this guide](https://e2b.dev/docs/guide/custom-sandbox)
66

7-
If you want to add another packages, another kernels or simply change some configuration and still use CodeInterpreter SDK, you will need to follow these steps:
7+
2. Use prebuilt [E2B Code Interpreter image](https://hub.docker.com/r/e2bdev/code-interpreter). Add this to your `e2b.Dockerfile`
88

9-
1. Copy `jupyter_server_config.py`, `ipython_kernel_config.py` and `start-up.sh` from [this folder](./).
10-
2. Add following commands in your Dockerfile
9+
```Dockerfile
10+
FROM e2bdev/code-interpreter:latest
11+
```
1112

12-
```Dockerfile
13-
# Installs jupyter server and kernel
14-
RUN pip install jupyter-server ipykernel ipython
15-
RUN ipython kernel install --name "python3" --user
13+
3. Copy [`start-up.sh`](./start-up.sh) to the same directory where's your `e2b.toml`
1614
17-
# Copies jupyter server config
18-
COPY ./jupyter_server_config.py /home/user/.jupyter/
15+
4. Run the following in the directory with `e2b.toml`
16+
```sh
17+
e2b template build -c "/home/user/.jupyter/start-up.sh"`
18+
```
1919
20-
# Setups jupyter server
21-
COPY ./start-up.sh /home/user/.jupyter/
22-
RUN chmod +x /home/user/.jupyter/start-up.sh
23-
```
20+
5. Use your custom sandbox with Code Interpreter SDK
2421
25-
3. Add the following option `-c "/home/user/.jupyter/start-up.sh"` to `e2b template build` command or add this line to your `e2b.toml`.
22+
**Python**
23+
```python
24+
from e2b_code_interpreter import CodeInterpreter
25+
sandbox = CodeInterpreter("your-custom-sandbox-name")
26+
execution = sandbox.notebook.exec_cell("print('hello')")
2627
27-
```yaml
28-
start_cmd = "/home/user/.jupyter/start-up.sh"
29-
```
28+
# Or you can use `with`
29+
with CodeInterpreter("your-custom-sandbox-name") as sandbox:
30+
execution = sandbox.notebook.exec_cell("print('hello')")
31+
```
32+
3033
31-
## Use E2B code interpreter image
32-
33-
Alternatively you can use prebuilt E2B Code Interpreter image. You can find it on Docker Hub: [e2b/code-interpreter](https://hub.docker.com/r/e2bdev/code-interpreter). You can simply write
34-
35-
```Dockerfile
36-
FROM e2bdev/code-interpreter:latest
37-
```
38-
39-
instead of the step `1` and `2` above. You still HAVE TO add the `start_cmd` option to your `e2b.toml` or `e2b template build` command.
34+
**JavaScript/TypeScript**
35+
```js
36+
import { CodeInterpreter } from '@e2b/code-interpreter'
37+
const sandbox = await CodeInterpreter.create('your-custom-sandbox-name')
38+
const execution = await sandbox.notebook.execCell('print("hello")')
39+
```

0 commit comments

Comments
 (0)