-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
111 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Getting help | ||
|
||
If you have any questions, issues, or feature requests, please reach out on of the following channels: {{ className: 'lead' }} | ||
- Send us an email at [hello@e2b.dev](mailto:hello@e2b.dev) | ||
- Talk to us on our [Discord server](https://discord.gg/U7KEcGErtQ) | ||
- Open an issue on [our GitHub](https://github.com/e2b-dev/e2b) | ||
- Reach out on [Twitter / X](https://twitter.com/e2b_dev) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Download files from sandbox | ||
Any file inside the sandbox can be downloaded using the `downloadFile`/`download_file` method. | ||
|
||
## Use case for downloading files | ||
For example, the download file method is useful for downloading any files produced by LLM. You can let LLM generate and execute code inside the sandbox. | ||
This LLM-generated code might produce some files like charts, CSV files, or PDF file that you want to download to your machine. | ||
|
||
<CodeGroupAutoload path="basics/download_file" isRunnable={false}/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Upload files to sandbox | ||
You can upload any file to the sandbox. This is useful if you want to let the LLM work with your files or files of your users. The file will be uploaded to the user's home directory with the same name. If a file with the same name already exists, it will be overwritten. | ||
|
||
## Use case for uploading files | ||
A popular workflow is for example to upload a CSV data file and then let the LLM generate and execute Python code that operates with the uploaded CSV file inside the sandbox. This way, you can essentially create your own AI data analyst or code interpreter. | ||
|
||
<Note> | ||
We support uploading files up to the 100MB at the moment. If you need to upload larger files, please [reach out to us](/getting-help). | ||
</Note> | ||
|
||
<CodeGroupAutoload path="basics/upload_file" isRunnable={false}/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
# Sandbox URL | ||
Each sandbox is accessible from the internet via a unique URL of that sandbox. | ||
Each sandbox has its own URL that you can use to connect to any service running inside the sandbox. | ||
|
||
<CodeGroupAutoload path="basics/get_url" isRunnable={true} /> | ||
For example, you can start a server inside the sandbox and connect to it from your browser. | ||
|
||
<CodeGroupAutoload path="basics/get_url" isRunnable={true} /> | ||
|
||
|
||
If you want to get an URL for a specific port inside the sanbdox, pass the port number to the `getHostname()`/`get_hostname()` method. | ||
<CodeGroupAutoload path="basics/get_url_port" isRunnable={true} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Session } from '@e2b/sdk' | ||
import fs from 'node:fs' | ||
|
||
const session = await Session.create({ id: 'Nodejs' }) | ||
|
||
const buffer = await session.downloadFile('path/to/remote/file/inside/sandbox') // $HighlightLine | ||
// Save file to local filesystem | ||
fs.writeFileSync('path/to/local/file', buffer) | ||
|
||
await session.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Session } from '@e2b/sdk' | ||
import fs from 'node:fs' | ||
|
||
const session = await Session.create({ id: 'Nodejs' }) | ||
|
||
// If you're in the server environment | ||
const filename = 'data.csv' // $HighlightLine | ||
const fileBuffer = fs.readFileSync('path/to/local/file') // $HighlightLine | ||
const remotePath = await session.uploadFile(fileBuffer, filename) // $HighlightLine | ||
|
||
// If you're in the browser environment, you can use the Blob API | ||
// const filename = 'data.csv' | ||
// const CSV = [ | ||
// '"1","val1","val2","val3","val4"', | ||
// '"2","val1","val2","val3","val4"', | ||
// '"3","val1","val2","val3","val4"' | ||
// ].join('\n'); | ||
// const fileBlob = new Blob([csv], { type: 'text/csv' }) | ||
// const remotePath = await session.uploadFile(fileBlob, 'data.csv') | ||
|
||
console.log(`The file was uploaded to '${remotePath}' path inside the sandbox `) | ||
|
||
await session.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from e2b import Session | ||
|
||
session = Session.create(id="Nodejs") | ||
|
||
file_in_bytes = session.download_file('path/to/remote/file/inside/sandbox') # $HighlightLine | ||
# Save file to local filesystem | ||
with open('path/to/local/file', 'wb') as f: # $HighlightLine | ||
f.write(file_in_bytes) # $HighlightLine | ||
|
||
session.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from e2b import Session | ||
|
||
session = Session.create(id="Nodejs") | ||
|
||
url = session.get_hostname() # $HighlightLine | ||
print("https://" + url) | ||
|
||
session.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from e2b import Session | ||
|
||
session = Session.create(id="Nodejs") | ||
|
||
with open('path/to/local/file', 'rb') as f: | ||
remote_path = session.upload_file(f) # $HighlightLine | ||
|
||
session.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8532272
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
e2b-docs – ./apps/docs
e2b-docs.vercel.app
e2b-docs-e2b.vercel.app
e2b-docs-git-main-e2b.vercel.app