Skip to content

Commit 2cbdc29

Browse files
authored
Quickstart updates (#65)
* Add link for dashboard to API key * Update claude model and prompt * Add dynamically updated libraries in code-interpreter * Add loading of .env to code examples * Syntax errors + missing dotenv imports * more fixes + edited sbx.upload example * add sandbox spawn for connect example * fix sandbox/connect highlights * removing dotenv import from code snippets * move libraries info from component * last dotenv remove * unified single quotes for imports * Remove/unify dotenv imports * fix spaces + code snippet
1 parent d5dd9e3 commit 2cbdc29

28 files changed

+212
-133
lines changed

docs/code-interpreting/analyze-data-with-ai.mdx

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,16 @@ These are the columns:
140140
- 'vote_average': float number between 0 and 10 that's representing viewers voting average
141141
- 'vote_count': int for how many viewers voted
142142
143-
I want to better understand how the vote average has changed over the years. Write Python code that analyzes the dataset based on my request and produces right chart accordingly`
143+
Write Python code that creates a line chart showing how vote_average changed over the years.
144+
Do NOT print or explore the data. Just create the visualization directly.
145+
146+
CRITICAL: Your code MUST end with this exact line to display the plot:
147+
display(plt.gcf())`
144148

145149
const anthropic = new Anthropic()
146150
console.log('Waiting for the model response...')
147151
const msg = await anthropic.messages.create({
148-
model: 'claude-3-5-sonnet-20240620',
152+
model: 'claude-haiku-4-5-20251001',
149153
max_tokens: 1024,
150154
messages: [{ role: 'user', content: prompt }],
151155
})
@@ -154,8 +158,8 @@ const msg = await anthropic.messages.create({
154158
```python Python
155159
from anthropic import Anthropic
156160

157-
prompt = '''
158-
I have a CSV file about movies. It has about 10k rows. It's saved in the sandbox at {datasetPathInSandbox.path}.
161+
prompt = f'''
162+
I have a CSV file about movies. It has about 10k rows. It's saved in the sandbox at {dataset_path_in_sandbox.path}.
159163
These are the columns:
160164
- 'id': number, id of the movie
161165
- 'original_language': string like "eng", "es", "ko", etc
@@ -167,11 +171,15 @@ These are the columns:
167171
- 'vote_average': float number between 0 and 10 that's representing viewers voting average
168172
- 'vote_count': int for how many viewers voted
169173
170-
I want to better understand how the vote average has changed over the years. Write Python code that analyzes the dataset based on my request and produces right chart accordingly'''
174+
Write Python code that creates a line chart showing how vote_average changed over the years.
175+
Do NOT print or explore the data. Just create the visualization directly.
176+
177+
CRITICAL: Your code MUST end with this exact line to display the plot:
178+
display(plt.gcf())'''
171179

172180
anthropic = Anthropic()
173181
msg = anthropic.messages.create(
174-
model='claude-3-5-sonnet-20240620',
182+
model='claude-haiku-4-5-20251001',
175183
max_tokens=1024,
176184
messages=[
177185
{"role": "user", "content": prompt}
@@ -189,7 +197,7 @@ Update the initialization of the Anthropic client to include the tool use like t
189197
<CodeGroup>
190198
```js JavaScript & TypeScript highlight={5-20}
191199
const msg = await anthropic.messages.create({
192-
model: 'claude-3-5-sonnet-20240620',
200+
model: 'claude-haiku-4-5-20251001',
193201
max_tokens: 1024,
194202
messages: [{ role: 'user', content: prompt }],
195203
tools: [
@@ -212,7 +220,7 @@ const msg = await anthropic.messages.create({
212220
```
213221
```python Python highlight={7-19}
214222
msg = anthropic.messages.create(
215-
model='claude-3-5-sonnet-20240620',
223+
model='claude-haiku-4-5-20251001',
216224
max_tokens=1024,
217225
messages=[
218226
{"role": "user", "content": prompt}
@@ -304,7 +312,10 @@ async function runAIGeneratedCode(aiGeneratedCode: string) {
304312
}
305313
}
306314
```
307-
```python Python highlight={7-12,15-17,20-23}
315+
```python Python highlight={1-2,7-12,15-17,20-23}
316+
import sys
317+
import base64
318+
308319
def run_ai_generated_code(ai_generated_code: str):
309320
print('Running the code in the sandbox....')
310321
execution = sbx.run_code(ai_generated_code)
@@ -381,14 +392,14 @@ async function runAIGeneratedCode(aiGeneratedCode: string) {
381392
// Save the png to a file
382393
// The png is in base64 format.
383394
fs.writeFileSync(`chart-${resultIdx}.png`, result.png, { encoding: 'base64' })
384-
console.log('Chart saved to chart-${resultIdx}.png')
395+
console.log(`Chart saved to chart-${resultIdx}.png`)
385396
resultIdx++
386397
}
387398
}
388399
}
389400

390401
const prompt = `
391-
I have a CSV file about movies. It has about 10k rows. It's saved in the sandbox at ${datasetPathInSandbox.path}.
402+
I have a CSV file about movies. It has about 10k rows. It's saved in the sandbox at ${dataset_path_in_sandbox.path}.
392403
These are the columns:
393404
- 'id': number, id of the movie
394405
- 'original_language': string like "eng", "es", "ko", etc
@@ -400,12 +411,16 @@ These are the columns:
400411
- 'vote_average': float number between 0 and 10 that's representing viewers voting average
401412
- 'vote_count': int for how many viewers voted
402413
403-
I want to better understand how the vote average has changed over the years. Write Python code that analyzes the dataset based on my request and produces right chart accordingly`
414+
Write Python code that creates a line chart showing how vote_average changed over the years.
415+
Do NOT print or explore the data. Just create the visualization directly.
416+
417+
CRITICAL: Your code MUST end with this exact line to display the plot:
418+
display(plt.gcf())`
404419

405420
const anthropic = new Anthropic()
406421
console.log('Waiting for the model response...')
407422
const msg = await anthropic.messages.create({
408-
model: 'claude-3-5-sonnet-20240620',
423+
model: 'claude-haiku-4-5-20251001',
409424
max_tokens: 1024,
410425
messages: [{ role: 'user', content: prompt }],
411426
tools: [
@@ -495,13 +510,16 @@ These are the columns:
495510
- 'vote_average': float number between 0 and 10 that's representing viewers voting average
496511
- 'vote_count': int for how many viewers voted
497512
498-
I want to better understand how the vote average has changed over the years.
499-
Write Python code that analyzes the dataset based on my request and produces right chart accordingly"""
513+
Write Python code that creates a line chart showing how vote_average changed over the years.
514+
Do NOT print or explore the data. Just create the visualization directly.
515+
516+
CRITICAL: Your code MUST end with this exact line to display the plot:
517+
display(plt.gcf())"""
500518

501519
anthropic = Anthropic()
502520
print("Waiting for model response...")
503521
msg = anthropic.messages.create(
504-
model='claude-3-5-sonnet-20240620',
522+
model='claude-haiku-4-5-20251001',
505523
max_tokens=1024,
506524
messages=[
507525
{"role": "user", "content": prompt}

docs/code-interpreting/analyze-data-with-ai/pre-installed-libraries.mdx

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,8 @@
22
title: "Pre-installed libraries"
33
---
44

5-
The sandbox comes with a [set of pre-installed Python libraries](https://github.com/e2b-dev/code-interpreter/blob/main/template/requirements.txt) for data analysis
6-
but you can [install additional packages](/docs/quickstart/install-custom-packages):
7-
- `aiohttp` (v3.9.3)
8-
- `beautifulsoup4` (v4.12.3)
9-
- `bokeh` (v3.3.4)
10-
- `gensim` (v4.3.2)
11-
- `imageio` (v2.34.0)
12-
- `joblib` (v1.3.2)
13-
- `librosa` (v0.10.1)
14-
- `matplotlib` (v3.8.3)
15-
- `nltk` (v3.8.1)
16-
- `numpy` (v1.26.4)
17-
- `opencv-python` (v4.9.0.80)
18-
- `openpyxl` (v3.1.2)
19-
- `pandas` (v1.5.3)
20-
- `plotly` (v5.19.0)
21-
- `pytest` (v8.1.0)
22-
- `python`-docx (v1.1.0)
23-
- `pytz` (v2024.1)
24-
- `requests` (v2.26.0)
25-
- `scikit-image` (v0.22.0)
26-
- `scikit-learn` (v1.4.1.post1)
27-
- `scipy` (v1.12.0)
28-
- `seaborn` (v0.13.2)
29-
- `soundfile` (v0.12.1)
30-
- `spacy` (v3.7.4)
31-
- `textblob` (v0.18.0)
32-
- `tornado` (v6.4)
33-
- `urllib3` (v1.26.7)
34-
- `xarray` (v2024.2.0)
35-
- `xlrd` (v2.0.1)
36-
- `sympy` (v1.12)
5+
import { Requirements } from '/snippets/SandboxPackages.jsx';
6+
7+
The sandbox comes with a <a href="https://github.com/e2b-dev/code-interpreter/blob/main/template/requirements.txt">set of pre-installed Python libraries</a> for data analysis but you can <a href="/docs/quickstart/install-custom-packages">install additional packages</a>
8+
9+
<Requirements />

docs/code-interpreting/supported-languages/javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The E2B Code Interpreter supports TypeScript, top-level await, ESM-style imports
1212

1313
<CodeGroup>
1414
```js JavaScript & TypeScript
15-
import { Sandbox } from "@e2b/code-interpreter";
15+
import { Sandbox } from '@e2b/code-interpreter';
1616

1717
// Create a new sandbox
1818
const sbx = await Sandbox.create();

docs/commands.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ console.log(result)
1717
from e2b_code_interpreter import Sandbox
1818

1919
sandbox = Sandbox.create()
20-
2120
result = sandbox.commands.run('ls -l')
2221
print(result)
2322
```

docs/commands/background.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const command = await sandbox.commands.run('echo hello; sleep 10; echo world', {
2323
// Kill the command
2424
await command.kill()
2525
```
26-
```python Python
26+
```python Python highlight={6}
2727
from e2b_code_interpreter import Sandbox
2828

2929
sandbox = Sandbox.create()

docs/commands/streaming.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ or the `on_stdout`, `on_stderr` callbacks to the `commands.run()` method in Pyth
1111
import { Sandbox } from '@e2b/code-interpreter'
1212

1313
const sandbox = await Sandbox.create()
14+
1415
const result = await sandbox.commands.run('echo hello; sleep 1; echo world', {
1516
onStdout: (data) => {
1617
console.log(data)

docs/filesystem/read-write.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ You can read files from the sandbox filesystem using the `files.read()` method.
1010
<CodeGroup>
1111
```js JavaScript & TypeScript
1212
import { Sandbox } from '@e2b/code-interpreter'
13+
1314
const sandbox = await Sandbox.create()
1415
const fileContent = await sandbox.files.read('/path/to/file')
1516
```
@@ -28,6 +29,7 @@ You can write single files to the sandbox filesystem using the `files.write()` m
2829
<CodeGroup>
2930
```js JavaScript & TypeScript
3031
import { Sandbox } from '@e2b/code-interpreter'
32+
3133
const sandbox = await Sandbox.create()
3234

3335
await sandbox.files.write('/path/to/file', 'file content')
@@ -37,7 +39,7 @@ from e2b_code_interpreter import Sandbox
3739

3840
sandbox = Sandbox.create()
3941

40-
await sandbox.files.write('/path/to/file', 'file content')
42+
sandbox.files.write('/path/to/file', 'file content')
4143
```
4244
</CodeGroup>
4345

@@ -48,6 +50,7 @@ You can also write multiple files to the sandbox.
4850
<CodeGroup>
4951
```js JavaScript & TypeScript
5052
import { Sandbox } from '@e2b/code-interpreter'
53+
5154
const sandbox = await Sandbox.create()
5255

5356
await sandbox.files.write([
@@ -60,7 +63,7 @@ from e2b_code_interpreter import Sandbox
6063

6164
sandbox = Sandbox.create()
6265

63-
await sandbox.files.write_files([
66+
sandbox.files.write_files([
6467
{ "path": "/path/to/a", "data": "file content" },
6568
{ "path": "another/path/to/b", "data": "file content" }
6669
])

docs/filesystem/upload.mdx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import requests
7070
sandbox = Sandbox.create(timeout=12_000, secure=True)
7171

7272
# Create a pre-signed URL for file upload with a 10 second expiration
73-
signed_url = sbx.upload_url(path="demo.txt", user="user", use_signature_expiration=10_000)
73+
signed_url = sandbox.upload_url(path="demo.txt", user="user", use_signature_expiration=10_000)
7474

7575
form_data = {"file":"file content"}
7676
requests.post(signed_url, data=form_data)
@@ -81,9 +81,6 @@ requests.post(signed_url, data=form_data)
8181

8282
<CodeGroup>
8383
```js JavaScript & TypeScript
84-
const fs = require('fs');
85-
const path = require('path');
86-
8784
import { Sandbox } from '@e2b/code-interpreter'
8885

8986
const sandbox = await Sandbox.create()
@@ -114,7 +111,7 @@ const readDirectoryFiles = (directoryPath) => {
114111
};
115112

116113
// Usage example
117-
const files = readDirectoryContents('/local/dir');
114+
const files = readDirectoryFiles('/local/dir');
118115
console.log(files);
119116
// [
120117
// { path: '/local/dir/file1.txt', data: 'File 1 contents...' },
@@ -151,11 +148,11 @@ def read_directory_files(directory_path):
151148
files = read_directory_files("/local/dir")
152149
print(files)
153150
# [
154-
# {"'path": "/local/dir/file1.txt", "data": "File 1 contents..." },
151+
# {"path": "/local/dir/file1.txt", "data": "File 1 contents..." },
155152
# { "path": "/local/dir/file2.txt", "data": "File 2 contents..." },
156153
# ...
157154
# ]
158155

159-
sandbox.files.write(files)
156+
sandbox.files.write_files(files)
160157
```
161158
</CodeGroup>

docs/filesystem/watch.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const handle = await sandbox.files.watchDir(dirname, async (event) => {
2929
await sandbox.files.write(`${dirname}/my-file`, 'hello')
3030
```
3131
```python Python highlight={7,12-16}
32-
from e2b_code_interpreter import Sandbox
32+
from e2b_code_interpreter import Sandbox, FilesystemEventType
3333

3434
sandbox = Sandbox.create()
3535
dirname = '/home/user'
@@ -43,7 +43,7 @@ sandbox.files.write(f"{dirname}/my-file", "hello")
4343
events = handle.get_new_events()
4444
for event in events:
4545
print(event)
46-
if event.type == FilesystemEventType.Write:
46+
if event.type == FilesystemEventType.WRITE:
4747
print(f"wrote to file {event.name}")
4848
```
4949
</CodeGroup>
@@ -78,7 +78,7 @@ const handle = await sandbox.files.watchDir(dirname, async (event) => {
7878
await sandbox.files.write(`${dirname}/my-folder/my-file`, 'hello')
7979
```
8080
```python Python highlight={7,9}
81-
from e2b_code_interpreter import Sandbox
81+
from e2b_code_interpreter import Sandbox, FilesystemEventType
8282

8383
sandbox = Sandbox.create()
8484
dirname = '/home/user'
@@ -92,7 +92,7 @@ sandbox.files.write(f"{dirname}/my-folder/my-file", "hello")
9292
events = handle.get_new_events()
9393
for event in events:
9494
print(event)
95-
if event.type == FilesystemEventType.Write:
95+
if event.type == FilesystemEventType.WRITE:
9696
print(f"wrote to file {event.name}")
9797
```
9898
</CodeGroup>

docs/legacy/code-interpreter/examples.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ plt.show()
107107

108108
<CodeGroup isRunnable={false}>
109109
```js JavaScript & TypeScript
110-
import { CodeInterpreter } from "@e2b/code-interpreter";
110+
import { CodeInterpreter } from '@e2b/code-interpreter';
111111

112112
code = `
113113
import time

0 commit comments

Comments
 (0)