Skip to content

armgit / E2B

Public Imported from GitHub
0

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

docs: make the initial page clearer

Vasek Mlejnsky654bf87d90e8
diff --git a/apps/docs/src/app/agents/deps/page.mdx b/apps/docs/src/app/agents/deps/page.mdx
new file mode 100644
index 000000000..e1f8b5cb4
--- /dev/null
+++ b/apps/docs/src/app/agents/deps/page.mdx
@@ -0,0 +1,19 @@
+export const metadata = {
+ title: 'E2B Documentation - Cloud for AI Agents Apps',
+ description: 'AI Agents - Install Dependencies',
+}
+
+# Install Dependencies
+
+You can install dependencies, libraries, and packages right inside the AI Playgrounds using the [`process()`](/playgrounds/process) method.
+
+This is especially useful when you want to run code generated by LLM that requires additional dependencies.
+
+## Install Python packages
+
+## Install NPM packages
+
+<CodeGroupAutoload
+ path="agents/install_deps_npm"
+ isRunnable={true}
+/>
diff --git a/apps/docs/src/app/page.mdx b/apps/docs/src/app/page.mdx
index 295bdd785..2c930d253 100644
--- a/apps/docs/src/app/page.mdx
+++ b/apps/docs/src/app/page.mdx
@@ -2,7 +2,7 @@ import { Guides } from '@/components/Guides'
import { UseCases } from '@/components/UseCases'
import { HeroPattern } from '@/components/HeroPattern'
import { Button } from '@/components/Button'
-import { ButtonLoginToken } from '@/components/ButtonLoginToken';
+import { ButtonLoginToken } from '@/components/ButtonLoginToken'
export const metadata = {
title: 'E2B Documentation - Cloud for AI Agents Apps',
@@ -19,39 +19,44 @@ export const sections = [
# What is E2B?
-**E2B is cloud for AI agents and AI apps.**{{ className: 'lead' }}
+**Sandboxed cloud environments for AI agents & AI apps {{ className: 'lead' }}**
With E2B, you can create AI playgrounds. In these AI playgrounds, you can let your AI agents and apps:
-- Run any code and terminal command in a sandboxed environment
+
+- [Run any code](/agents/exec) and terminal command in a sandboxed environment
+- [Start any process]() (even long-running such as a database)
+- [Run any shell command](/agents/shell-commands)
+- [Upload and download files](/playgrounds/filesystem#write-bytes)
- Install dependencies and programs
-- Use filesystem
-- Upload and download files
+- [Use filesystem](/playgrounds/filesystem)
- Access the internet
- Start a web server that's accessible from the internet
-- Clone git repositories
-- Start any process (even long-running such as a database)
-
-This just a few examples of what can be done with our agent cloud environments.
-
-Our SDK works with any AI agent (no matter what framework you're using), and without the need to manage any infrastructure.
+- [Clone git repositories](/agents/clone-repo)
<div className="not-prose mb-16 mt-6 flex items-center gap-3">
- <Button href="/getting-started/installation" arrow="right" children="Getting Started" />
+ <Button
+ href="/getting-started/installation"
+ arrow="right"
+ children="Getting Started"
+ />
<ButtonLoginToken />
</div>
-## Quickstart Example
+## Start cloud playground
<CodeGroup isRunnable={false}>
```bash {{ language: 'js' }}
npm i @e2b/sdk
```
+
```bash {{ language: 'python' }}
pip install e2b
```
</CodeGroup>
-<CodeGroupAutoload path="quickstart" isRunnable={false} />
-
+<CodeGroupAutoload
+ path="quickstart"
+ isRunnable={false}
+/>
diff --git a/apps/docs/src/code/js/agents/install_deps_npm.js b/apps/docs/src/code/js/agents/install_deps_npm.js
new file mode 100644
index 000000000..95273c5c3
--- /dev/null
+++ b/apps/docs/src/code/js/agents/install_deps_npm.js
@@ -0,0 +1,38 @@
+import { Session } from '@e2b/sdk'
+
+// 1. Start the playground session
+const session = await Session.create({
+ // Note we're using the 'Nodejs' runtime here since we want to run Node.js code
+ // and install NPM dependencies
+ id: 'Nodejs', // $HighlightLine
+ apiKey: process.env.E2B_API_KEY,
+})
+
+// 2. Install packages using NPM inside the /code directory
+console.log('Installing lodash...')
+const proc = await session.process.start({
+ cmd: 'npm install lodash', // $HighlightLine
+ rootdir: '/code', // $HighlightLine
+ onStdout: (data) => console.log('[INFO] ', data.line),
+ onStderr: (data) => console.log('[WARN | ERROR] ', data.line),
+})
+// Wait for the process to finish
+await proc.finished
+
+// We can now use lodash in our code
+const code = `
+ const _ = require(
+ 'lodash');
+ console.log(_.camelCase('Hello World'));
+`
+await session.filesystem.write('/code/index.js', code)
+// Run the code
+console.log('Running code...')
+const codeRun = await session.process.start({
+ cmd: 'node /code/index.js',
+ onStdout: (data) => console.log('[INFO] ', data.line),
+ onStderr: (data) => console.log('[WARN | ERROR] ', data.line),
+})
+await codeRun.finished
+
+await session.close()
diff --git a/apps/docs/src/code/js/quickstart.js b/apps/docs/src/code/js/quickstart.js
index e09965ebc..81377de7c 100644
--- a/apps/docs/src/code/js/quickstart.js
+++ b/apps/docs/src/code/js/quickstart.js
@@ -1,9 +1,19 @@
import { Session } from '@e2b/sdk'
-const session = await Session.create({
- // We're working on custom environments
+// 1. Start cloud playground
+const session = await Session.create({ // $HighlightLine
id: 'Nodejs', // or 'Bash', 'Python3', 'Java', 'Go', 'Rust', 'PHP', 'Perl', 'DotNET'
apiKey: process.env.E2B_API_KEY,
})
+// 2. Use filesystem
+session.filesystem // $HighlightLine
+
+// 3. Start processes
+session.process.start() // $HighlightLine
+
+// 4. Upload/download files
+session.read_bytes() // $HighlightLine
+session.write_bytes() // $HighlightLine
+
await session.close()
diff --git a/apps/docs/src/code/python/quickstart.py b/apps/docs/src/code/python/quickstart.py
index 81f955561..cfab0aa93 100644
--- a/apps/docs/src/code/python/quickstart.py
+++ b/apps/docs/src/code/python/quickstart.py
@@ -4,11 +4,22 @@ from e2b import Session
E2B_API_KEY = getenv("E2B_API_KEY")
+# 1. Start cloud playground
async def main():
# `id` can also be one of:
# 'Nodejs', 'Bash', 'Python3', 'Java', 'Go', 'Rust', 'PHP', 'Perl', 'DotNET'
- # We're working on custom environments.
- session = await Session.create(id="Nodejs", api_key=E2B_API_KEY)
+ session = await Session.create(id="Nodejs", api_key=E2B_API_KEY) # $HighlightLine
+
+ # 2. Use filesystem
+ session.filesystem # $HighlightLine
+
+ # 3. Start processes
+ session.process.start() # $HighlightLine
+
+ # 4. Upload/download files
+ session.read_bytes() # $HighlightLine
+ session.write_bytes() # $HighlightLine
+
await session.close()
asyncio.run(main())
\ No newline at end of file
diff --git a/apps/docs/src/components/Navigation.tsx b/apps/docs/src/components/Navigation.tsx
index 2146c7fd8..6be528427 100644
--- a/apps/docs/src/components/Navigation.tsx
+++ b/apps/docs/src/components/Navigation.tsx
@@ -299,7 +299,7 @@ export const navigation = [
],
},
{
- title: 'AI Playgrounds',
+ title: 'AI Playgrounds SDK',
links: [
{ title: 'Overview', href: '/playgrounds/overview' },
{
@@ -378,7 +378,7 @@ export const navigation = [
title: 'AI Agents Use Case',
links: [
{ title: 'Execute Code', href: '/agents/exec' },
- // { title: 'Install Packages', href: '/agents/pkg' },
+ { title: 'Installing Dependencies', href: '/agents/deps' },
{ title: 'Clone GitHub Repository', href: '/agents/clone-repo' },
{ title: 'Run Shell Commands', href: '/agents/shell-commands' },
// { title: 'Read File', href: '/agents/read' },