Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

WIP: Docs

Jakub Novakc1899621f57e
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 7180ff610..e59373271 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -73,6 +73,26 @@
// Disable Pylint and use just Pylance
"python.linting.enabled": false,
"python.analysis.typeCheckingMode": "basic",
+ "workbench.colorCustomizations": {
+ "activityBar.activeBackground": "#9163ec",
+ "activityBar.background": "#9163ec",
+ "activityBar.foreground": "#15202b",
+ "activityBar.inactiveForeground": "#15202b99",
+ "activityBarBadge.background": "#f1af8d",
+ "activityBarBadge.foreground": "#15202b",
+ "commandCenter.border": "#e7e7e799",
+ "sash.hoverBorder": "#9163ec",
+ "statusBar.background": "#7136e6",
+ "statusBar.foreground": "#e7e7e7",
+ "statusBarItem.hoverBackground": "#9163ec",
+ "statusBarItem.remoteBackground": "#7136e6",
+ "statusBarItem.remoteForeground": "#e7e7e7",
+ "titleBar.activeBackground": "#7136e6",
+ "titleBar.activeForeground": "#e7e7e7",
+ "titleBar.inactiveBackground": "#7136e699",
+ "titleBar.inactiveForeground": "#e7e7e799"
+ },
+ "peacock.color": "#7136e6",
// "python.analysis.pylanceLspClientEnabled": true,
// "python.analysis.inlayHints.functionReturnTypes": true,
// "python.analysis.inlayHints.pytestParameters": true,
diff --git a/apps/docs/src/app/code-interpreter/execution/page.mdx b/apps/docs/src/app/code-interpreter/execution/page.mdx
new file mode 100644
index 000000000..2dadae534
--- /dev/null
+++ b/apps/docs/src/app/code-interpreter/execution/page.mdx
@@ -0,0 +1,94 @@
+# Execution explained
+
+The object returned by the `execCell` method is little bit more complex, it's based on Jupyter. Here's an detailed explanation in the [Jupyter documentation](https://jupyter-client.readthedocs.io/en/stable/messaging.html).
+
+It contains the following fields:
+
+- `results`: A list containing result of the cell (interactively interpreted last line) and display calls (e.g. matplotlib plots).
+- `logs`: Logs printed to stdout and stderr during execution.
+- `error`: An error message, if there was an error during execution of the cell. It works only for Python code, not for system (`!`) commands.
+
+## Result object
+
+There are two main types of results:
+- Last line result: The result of the last line of the cell, which is interpreted as the result of the cell. As you would expect in REPL environments.
+- Display calls: Calls to display functions, which can be used to display rich output in the notebook.
+
+Represents the data to be displayed as a result of executing a cell in a Jupyter notebook.
+The result is similar to the structure returned by [ipython kernel](https://ipython.readthedocs.io/en/stable/development/execution.html#execution-semantics)
+
+The result can contain multiple types of data, such as text, images, plots, etc. Each type of data is represented
+as a string, and the result can contain multiple types of data. The text representation is always present, and
+the other representations are optional.
+
+The result has those basic data types:
+
+Text types:
+- text: text representation of the result, it's always present
+- html: html representation of the result
+- markdown: markdown representation of the result
+- latex: latex representation of the result
+
+Image types:
+ - "image/png": "base64 encoded png image",
+ - "image/jpeg": "base64 encoded jpeg image",
+ - "image/svg+xml": "svg image",
+
+ Other types:
+ - "application/json": "json representation",
+ - "application/javascript": "javascript representation",
+ - "application/pdf": "base64 encoded pdf",
+ - "application/geo+json": "geojson
+
+## Logs object
+
+Logs printed to stdout and stderr during execution. Examples of logs are print statements, warnings, subprocess output, etc.
+
+## Error object
+
+An error message, if there was an error during execution of the cell.
+<Note>
+It works only for Python code, not for system (e.g. `!pip install non_existent_package`) commands. The system commands are executed in a separate process and the output is in stdout/stderr.
+</Note>
+
+## Example how to interpret the results to LLM
+
+Here's an example how to return the results to LLM:
+
+<CodeGroup isRunnable={false}>
+```js
+const code = `<CODE GENERATED BY LLM>`
+const execution = await sandbox.notebook.execCell(code)
+
+const message = ""
+if (execution.error) {
+ message = `There was an error during execution: ${execution.error.name}: ${execution.error.value}. Here's the traceback: ${execution.error.traceback}`
+} else if (execution.results.length > 0) {
+ message = "There are results of the cell:\n"
+ let counter = 1
+ for (const result of execution.results) {
+ message += `Result ${counter++}:\n`
+ if (result.isMainResult) {
+ message += `Main result of the cell is: ${result.text}\n`
+ } else {
+ message += `Display call: ${result.text}\n`
+ }
+ message += `It has following formats: ${result.formats()}\n`
+ } else if (execution.logs.stdout.length > 0 || execution.logs.stderr.length > 0) {
+ message = "There are logs during execution:\n"
+ if (execution.logs.stdout.length > 0) {
+ message += `Stdout: ${execution.logs.stdout.join("\n")}\n`
+ }
+ if (execution.logs.stderr.length > 0) {
+ message += `Stderr: ${execution.logs.stderr.join("\n")}\n`
+ }
+ }
+
+}
+
+```
+
+```python
+pip install e2b
+```
+</CodeGroup>
diff --git a/apps/docs/src/app/code-interpreter/installation/page.mdx b/apps/docs/src/app/code-interpreter/installation/page.mdx
deleted file mode 100644
index 1fe04fd7e..000000000
--- a/apps/docs/src/app/code-interpreter/installation/page.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Libraries } from '@/components/Libraries'
-
-# Installation
-
-You can install the code interpreter using the following commands:
-
-<CodeGroup isRunnable={false}>
-```bash {{ language: 'js' }}
-npm install @e2b/code-interpreter
-```
-```bash {{ language: 'python' }}
-pip install e2b-code-interpreter
-```
-</CodeGroup>
-
-
-## Next steps
-
-1. [Follow the examples](/code-interpreter/examples/)
diff --git a/apps/docs/src/app/code-interpreter/overview/page.mdx b/apps/docs/src/app/code-interpreter/overview/page.mdx
index 5a8818040..c0f50c639 100644
--- a/apps/docs/src/app/code-interpreter/overview/page.mdx
+++ b/apps/docs/src/app/code-interpreter/overview/page.mdx
@@ -6,19 +6,8 @@ import {
# Code Interpreter
-<Link
- className="w-fit flex items-center justify-start space-x-2"
- href="https://github.com/e2b-dev/code-interpreter/blob/main/template"
- rel="noopener noreferrer"
- target="_blank"
->
- <FileCode
- size={18}
- className="text-brand-600"
- />
- Template source code
-</Link>
-
+The Code Interpreter template runs a Jupyter server inside the sandbox, which allows for sharing context between code executions.
+Additionally, this new template also partly implements the Jupyter Kernel messaging protocol. This means that, for example, support for plotting charts, rendering DataFrames, etc.
## Motivation
@@ -31,6 +20,19 @@ Additionally, this new template also partly implements the [Jupyter Kernel messa
The current code interpreter allows to run Python code but each run share the context. That means that subsequent runs can reference to variables, definitions, etc from past code execution runs.
+## Installation
+
+You can install the code interpreter using the following commands:
+
+<CodeGroup isRunnable={false}>
+```bash {{ language: 'js' }}
+npm install @e2b/code-interpreter
+```
+```bash {{ language: 'python' }}
+pip install e2b-code-interpreter
+```
+</CodeGroup>
+
## Features
- **Stateful Execution**: Unlike traditional sandboxes that treat each code execution independently, this package maintains context across executions.
diff --git a/apps/docs/src/app/code-interpreter/results/page.mdx b/apps/docs/src/app/code-interpreter/results/page.mdx
deleted file mode 100644
index a52cd4056..000000000
--- a/apps/docs/src/app/code-interpreter/results/page.mdx
+++ /dev/null
@@ -1,17 +0,0 @@
-# Results explained
-
-The object returned by the `execCell` method is little bit more complex, it's based on Jupyter. (there's an detailed explanation in the [Jupyter documentation](https://jupyter-client.readthedocs.io/en/stable/messaging.html).
-
-It contains the following fields:
-
-- `data`: An array of the output of the cell and also displayed data (e.g. plots or images)
-- `logs`: Logs printed to stdout and stderr during execution.
-- `error`: An error message, if there was an error during execution of the cell. It works only for Python code, not for system (`!`) commands.
-
-## Data object
-
-## Logs object
-
-## Error object
-
-## Example how to interpret the results
diff --git a/apps/docs/src/app/code-interpreter/template/page.mdx b/apps/docs/src/app/code-interpreter/template/page.mdx
index 841b25980..fa708be28 100644
--- a/apps/docs/src/app/code-interpreter/template/page.mdx
+++ b/apps/docs/src/app/code-interpreter/template/page.mdx
@@ -3,6 +3,21 @@
##
The template requires custom setup. If you want to build your own custom template and use Code Interpreter, you need to do:
+
+<Link
+ className="w-fit flex items-center justify-start space-x-2"
+ href="https://github.com/e2b-dev/code-interpreter/blob/main/template"
+ rel="noopener noreferrer"
+ target="_blank"
+>
+ <FileCode
+ size={18}
+ className="text-brand-600"
+ />
+ Template source code
+</Link>
+
+
Copy jupyter_server_config.py and start-up.sh from this PR
Add following commands in your Dockerfile
# Installs jupyter server and kernel
diff --git a/apps/docs/src/components/Navigation/routes.tsx b/apps/docs/src/components/Navigation/routes.tsx
index 09fa36cda..9d680d36d 100644
--- a/apps/docs/src/components/Navigation/routes.tsx
+++ b/apps/docs/src/components/Navigation/routes.tsx
@@ -201,15 +201,10 @@ export const routes = [
title: 'Overview',
href: '/code-interpreter/overview',
},
- {
- icon: <Cog strokeWidth={1} size={20} />,
- title: 'Installation',
- href: '/code-interpreter/installation',
- },
{
icon: <Lightbulb strokeWidth={1} size={20} />,
- title: 'Results explained',
- href: '/code-interpreter/results',
+ title: 'Execution explained',
+ href: '/code-interpreter/execution',
},
{
icon: <Book strokeWidth={1} size={20} />,
@@ -221,6 +216,11 @@ export const routes = [
title: 'Extending Code Interpreter',
href: '/code-interpreter/template',
},
+ {
+ icon: <Cog strokeWidth={1} size={20} />,
+ title: 'Kernels',
+ href: '/code-interpreter/kernels',
+ },
],
},
{