Skip to content

Commit

Permalink
Update code snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
mlejva committed Jul 31, 2024
1 parent 70bf687 commit ecd6fcc
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@ Each of the supported language runtimes has its own kernel.

**Python**
```python
with CodeInterpreter() as sandbox:
# 1. Set JS kernel - available kernel names: 'r', 'javascript', 'java', 'bash'
js_id = sandbox.notebook.create_kernel(kernel_name="javascript")
# 2. Run JS code inside code interpreter!
execution = sandbox.notebook.exec_cell("console.log('Hello World!')", kernel_id=js_id)
print(execution)
# 3. Use Python again
sandbox.notebook.exec_cell("print('Hello World!')")
from e2b_code_interpreter import CodeInterpreter

sandbox = CodeInterpreter()

# 1. Set JS kernel - available kernel names: 'r', 'javascript', 'java', 'bash'
js_id = sandbox.notebook.create_kernel(kernel_name="javascript")
# 2. Run JS code inside code interpreter!
execution = sandbox.notebook.exec_cell("console.log('Hello World!')", kernel_id=js_id)
print(execution)
# 3. Use Python again
sandbox.notebook.exec_cell("print('Hello World!')")
```

**JavaScript / TypeScript**
```js
import { CodeInterpreter } from '@e2b/code-interpreter'

const sandbox = await CodeInterpreter.create()

// 1. Set JS kernel - available kernel names: 'r', 'javascript', 'java', 'bash'
Expand All @@ -46,6 +51,4 @@ const execution = await sandbox.notebook.execCell("console.log('Hello World!')",
console.log(execution)
// 3. Use Python again
await sandbox.notebook.execCell('print("Hello World!")')

await sandbox.close()
```

0 comments on commit ecd6fcc

Please sign in to comment.