Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add API for data analysis [wip]
Vasek Mlejnsky76be2aa3bfe7
diff --git a/apps/docs/src/app/page.mdx b/apps/docs/src/app/page.mdxindex 904bbd2c2..9ab72eedf 100644--- a/apps/docs/src/app/page.mdx+++ b/apps/docs/src/app/page.mdx@@ -8,7 +8,7 @@ import { useSignIn } from '@/utils/useSignIn'<HeroPattern />-# Runtime Sandbox for Large Language Models+# Sandbox Runtime for Large Language ModelsSandboxes allow AI apps to have long running cloud environments where large language models can use the same tools as humans do. {{ className: 'lead' }}diff --git a/apps/docs/src/app/sandbox/templates/premade/page.mdx b/apps/docs/src/app/sandbox/templates/premade/page.mdxindex ec3e2df19..80c1fd416 100644--- a/apps/docs/src/app/sandbox/templates/premade/page.mdx+++ b/apps/docs/src/app/sandbox/templates/premade/page.mdx@@ -1,35 +1,145 @@+import Link from 'next/link'+import {+ FileCode,+} from 'lucide-react'+# Premade SandboxesTo get your started quickly, we offer a two premade sandboxes.-## `Base`+## Base+<Link+ className="w-fit flex items-center space-x-2 justify-start"+ href="https://github.com/e2b-dev/e2b/blob/main/templates/base/Dockerfile"+ rel="noopener noreferrer"+ target="_blank"+>+ <FileCode+ size={18}+ className="text-brand-600"+ />+ Template File+</Link>+<div className="pr-1 w-[320px] flex items-center justify-start space-x-2 border border-gray-600 rounded">+ <span className="font-mono text-sm w-8 h-8 flex items-center justify-center border-r border-gray-600">id</span>+ <span className="font-mono text-sm text-gray-200">base</span>+</div>++### FeaturesA "base" sandbox with Nodejs, Python 3, and essentials libraries like `curl`.- Ideal for getting started with the SDK.-- Inspect the template code [here](https://github.com/e2b-dev/e2b/blob/main/templates/base/Dockerfile).-## `DataAnalysis`-Sandbox with Python 3 and data science Python libraries like `pandas`, `numpy`, `matplotlib`.+### Usage++---++## Code Interpreter / Data Analysis+<Link+ className="w-fit flex items-center justify-start space-x-2"+ href="https://github.com/e2b-dev/e2b/blob/main/templates/data_analysis/Dockerfile"+ rel="noopener noreferrer"+ target="_blank"+>+ <FileCode+ size={18}+ className="text-brand-600"+ />+ Template File+</Link>++<div className="pr-1 w-[320px] flex items-center justify-start space-x-2 border border-gray-600 rounded">+ <span className="font-mono text-sm w-8 h-8 flex items-center justify-center border-r border-gray-600">id</span>+ <span className="font-mono text-sm text-gray-200">Python3-DataAnalysis</span>+</div>++### Features+Sandbox with Python 3 and data science Python libraries like `pandas`, `numpy`, or `matplotlib`.+- See the complete list of pre-installed Python packages [here](https://github.com/e2b-dev/e2b/blob/main/templates/data_analysis/requirements.txt).- Ideal for the Data Analysis and Code Interpreter use cases.-- Inspect the template code [here](https://github.com/e2b-dev/e2b/blob/main/templates/base/Dockerfile).-<CodeGroup title="Create DataAnalysis sandbox" isRunnable={false}>++### Usage+You can use all the regular [Sandbox API](/api/envs) inside the Code Interpreter / Data Analysis sandbox. On top of that, you can use a few extra methods specifcially made for the use case of code interpreter powered by an LLM.++- **Create sandbox**+<CodeGroup isRunnable={false}>```js {{ language: 'js' }}-import { Sandbox } from '@e2b/sdk'+import { DataAnalysis } from '@e2b/sdk'+const sandbox = await DataAnalysis.create()+```++```python {{ language: 'python' }}+from e2b import DataAnalysis+sandbox = DataAnalysis()+```+</CodeGroup>-const sandbox = await Sandbox.create({- id: 'Python3-DataAnalysis',-})+- **Run Python code**+<CodeGroup isRunnable={false}>+```js {{ language: 'js' }}+const llmGeneratedPythonCode = 'print("Hello World")'+ // `artifacts` are chart files created by matplotlib+const { stdout, stderr, artifacts } = await DataAnalysis.runPython(llmGeneratedPythonCode)-await sandbox.close()+// Retrieve chart files:+for (const artifact of artifacts) {+ const downloadedChart = await artifact.download()+ // Now you can save this file, send it to frontend, or anything else+}``````python {{ language: 'python' }}-from e2b import Sandbox+// Now you can save this file, send it to frontend, or anything else+const downloadedChart = await artifact.download()-sandbox = Sandbox(- id="Python3-DataAnalysis",-)+await sandbox.close()+```+```python {{ language: 'python' }}+llm_generated_python_code = 'print("Hello World")'+stdout, stderr, artifacts = DataAnalysis.run_python(llm_generated_python_code)sandbox.close()```</CodeGroup>++- **Install Python packages**+<CodeGroup isRunnable={false}>+```js {{ language: 'js' }}+await DataAnalysis.installPythonPackages('s3transfer')+await sandbox.close()+```+```python {{ language: 'python' }}+sandbox = DataAnalysis.install_python_packages('s3transfer')+sandbox.close()+```+</CodeGroup>++- **Install system packages**+<CodeGroup isRunnable={false}>+```js {{ language: 'js' }}+await DataAnalysis.installSystemPackages('ffmpeg')+await sandbox.close()+```+```python {{ language: 'python' }}+sandbox = DataAnalysis.install_system_packages('ffmpeg')+sandbox.close()+```+</CodeGroup>++{/* - Listen to new files generated by executed code (charts, images, etc)+<CodeGroup isRunnable={false}>+```js {{ language: 'js' }}+await DataAnalysis.installSystemPackages('ffmpeg')+await sandbox.close()+```+```python {{ language: 'python' }}+sandbox = DataAnalysis.install_system_packages('ffmpeg')+sandbox.close()+```+</CodeGroup> */}++{/* - Stream code output+- Stream code errors+- Upload file+- Download file */}+diff --git a/apps/docs/src/code/python/quickstart.py b/apps/docs/src/code/python/quickstart.pyindex 87a7e4b95..6752a334f 100644--- a/apps/docs/src/code/python/quickstart.py+++ b/apps/docs/src/code/python/quickstart.py@@ -1,24 +1,16 @@-from os import getenv-from e2b import Sandbox-E2B_API_KEY = getenv("E2B_API_KEY")-# 1. Start cloud playground-def main():- # `id` can be your own template id- sandbox = Sandbox(id="base", api_key=E2B_API_KEY) # $HighlightLine-- # 2. Use filesystem- sandbox.filesystem # $HighlightLine+sandbox = Sandbox() # $HighlightLine- # 3. Start processes- sandbox.process.start() # $HighlightLine+# 2. Use filesystem+sandbox.filesystem # $HighlightLine- # 4. Upload/download files- sandbox.read_bytes() # $HighlightLine- sandbox.write_bytes() # $HighlightLine+# 3. Start processes+sandbox.process.start() # $HighlightLine- sandbox.close()+# 4. Upload/download files+sandbox.read_bytes() # $HighlightLine+sandbox.write_bytes() # $HighlightLine-main()+sandbox.close()diff --git a/apps/docs/src/components/Code.tsx b/apps/docs/src/components/Code.tsxindex 9297f3a16..a217b8558 100644--- a/apps/docs/src/components/Code.tsx+++ b/apps/docs/src/components/Code.tsx@@ -224,7 +224,7 @@ export function CodeGroupHeader({<div className="flex flex-col items-start">{title && (<div className="pl-2 mt-3">- <h3 className="font-xs font-bold text-zinc-300">{title}</h3>+ <h3 className="font-xs font-medium text-brand-50">{title}</h3></div>)}{hasTabs && (diff --git a/apps/docs/src/components/Navigation/routes.tsx b/apps/docs/src/components/Navigation/routes.tsxindex 25395b91d..7ced79c28 100644--- a/apps/docs/src/components/Navigation/routes.tsx+++ b/apps/docs/src/components/Navigation/routes.tsx@@ -1,4 +1,5 @@import {+ Boxes,ChevronRightSquare,Cpu,DollarSign,@@ -16,7 +17,6 @@ import {Variable,PencilRuler,File,- Image as ImageIcon,} from 'lucide-react'export const routes = [@@ -149,7 +149,7 @@ export const routes = [},{icon: (- <ImageIcon+ <BoxesstrokeWidth={1}size={20}/>