Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Simplify docs for code interpretrer
Vasek Mlejnsky7cde0a8d949c
diff --git a/apps/docs/src/app/code-interpreter/installation/page.mdx b/apps/docs/src/app/code-interpreter/installation/page.mdxindex 905a2cafa..51fac52f5 100644--- a/apps/docs/src/app/code-interpreter/installation/page.mdx+++ b/apps/docs/src/app/code-interpreter/installation/page.mdx@@ -1,86 +1,54 @@-import Link from 'next/link'-import {- FileCode,-} from 'lucide-react'+# Code Interpreter SDK+E2B's [Code Interpreter SDK](https://github.com/e2b-dev/code-interpreter) allows you to add code interpreting capabilities to your AI apps.+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.+- ✅ Works with any LLM and AI framework+- ✅ Supports streaming content like charts and stdout, stderr+- ✅ Python & JS SDK+- ✅ Runs on serverless and edge functions+- ✅ Runs AI-generated code in secure sandboxed environments+- ✅ 100% open source (including [infrastructure](https://github.com/e2b-dev/infra))-# Code Interpreter+## Quickstart-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.+### 1. Install SDK-## Motivation--The code generated by LLMs is often split into code blocks, where each subsequent block references the previous one. This is a common pattern in Jupyter notebooks, where each cell can reference the variables and definitions from the previous cells. In the classical sandbox each code execution is independent and does not share the context with the previous executions.--This is suboptimal for a lot of Python use cases with LLMs. Especially GPT-3.5 and 4 expects it runs in a Jupyter Notebook environment. Even when ones tries to convince it otherwise. In practice, LLMs will generate code blocks which have references to previous code blocks. This becomes an issue if a user wants to execute each code block separately which often is the use case.--This new 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](https://jupyter-client.readthedocs.io/en/latest/messaging.html). This means that, for example, support for plotting charts is now improved.--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:+JavaScript/TypeScript+```+npm i @e2b/code-interpreter+```-<CodeGroup isRunnable={false}>-```bash {{ language: 'js' }}-npm install @e2b/code-interpreter+Python```-```bash {{ language: 'python' }}-pip install e2b-code-interpreter+pip install e2b_code_interpreter```-</CodeGroup>-## Features+### 2. Execute code with code interpreter inside sandbox-- **Stateful Execution**: Unlike traditional sandboxes that treat each code execution independently, this package maintains context across executions.-- **Displaying Graph & Data**: Implements parts of the [Jupyter Kernel messaging protocol](https://jupyter-client.readthedocs.io/en/latest/messaging.html), which support for interactive features like plotting charts, rendering DataFrames, etc.+**JavaScript**+```ts+import { CodeInterpreter } from '@e2b/code-interpreter'-## Typical Use Cases+const sandbox = await CodeInterpreter.create()+await sandbox.notebook.execCell('x = 1')-- **Interactive Code Interpreter**: Run code snippets and share context between them.-- **Data Analysis**: Analyze data and visualize it using charts.+const execution = await sandbox.notebook.execCell('x+=1; x')+console.log(execution.text) // outputs 2-## Pre-installed packages+await sandbox.close()+```-The full and always up-to-date list can be found in the [`requirements.txt`](https://github.com/e2b-dev/code-interpreter/blob/main/template/requirements.txt) file.+**Python**+```py+from e2b_code_interpreter import CodeInterpreter-```text-# Jupyter server requirements-jupyter-server==2.13.0-ipykernel==6.29.3-ipython==8.22.2+with CodeInterpreter() as sandbox:+ sandbox.notebook.exec_cell("x = 1")-# Other packages-aiohttp==3.9.3-beautifulsoup4==4.12.3-bokeh==3.3.4-gensim==4.3.2-imageio==2.34.0-joblib==1.3.2-librosa==0.10.1-matplotlib==3.8.3-nltk==3.8.1-numpy==1.26.4-opencv-python==4.9.0.80-openpyxl==3.1.2-pandas==1.5.3-plotly==5.19.0-pytest==8.1.0-python-docx==1.1.0-pytz==2024.1-requests==2.26.0-scikit-image==0.22.0-scikit-learn==1.4.1.post1-scipy==1.12.0-seaborn==0.13.2-soundfile==0.12.1-spacy==3.7.4-textblob==0.18.0-tornado==6.4-urllib3==1.26.7-xarray==2024.2.0-xlrd==2.0.1+ execution = sandbox.notebook.exec_cell("x+=1; x")+ print(execution.text) # outputs 2```++### 3. Hello World guide+Dive depeer and check out the [JavaScript](/hello-world/js) and [Python](/hello-world/py) the Hello World guides to learn how o connect code interpreter LLMs.+diff --git a/apps/docs/src/components/Navigation/routes.tsx b/apps/docs/src/components/Navigation/routes.tsxindex e4b11abca..005ff5ee6 100644--- a/apps/docs/src/components/Navigation/routes.tsx+++ b/apps/docs/src/components/Navigation/routes.tsx@@ -158,6 +158,11 @@ export const routes = [// title: 'Supported languages',// href: '/code-interpreter/template',// },+ // {+ // icon: <Wrench strokeWidth={1} size={20} />,+ // title: 'Preinstalled packages (customization)',+ // href: '/code-interpreter/template',+ // },{icon: <Wrench strokeWidth={1} size={20} />,title: 'Customization',