import Link from 'next/link'
import {
  FileCode,
} from 'lucide-react'

import { TemplateName } from './TemplateName'

# Premade Sandboxes

To get your started quickly, we offer two premade sandboxes.

## 1. Default Sandbox
<Link
  className="w-fit flex items-center space-x-2 justify-start"
  href="https://github.com/e2b-dev/e2b/blob/main/sandboxes/base/e2b.Dockerfile"
  rel="noopener noreferrer"
  target="_blank"
>
  <FileCode
    size={18}
    className="text-brand-600"
  />
  Template File
</Link>

<TemplateName templateName="base"/>

### Features
Ubuntu-based sandbox with Nodejs, Python 3, and essentials libraries like `curl`.
- Ideal for getting started with the SDK.

### Usage
The base sandbox has all the features of the [Sandbox API](/sandbox/api/envs) available.

---

## 2. Code Interpreter Sandbox
<Link
  className="w-fit flex items-center justify-start space-x-2"
  href="https://github.com/e2b-dev/e2b/blob/main/sandboxes/code-interpreter/e2b.Dockerfile"
  rel="noopener noreferrer"
  target="_blank"
>
  <FileCode
    size={18}
    className="text-brand-600"
  />
  Template File
</Link>

<TemplateName templateName="code-interpreter"/>

### Features
Ubuntu-based 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/sandboxes/code-interpreter/requirements.txt).
- Ideal for the Data Analysis and Code Interpreter use cases.


### Usage
You can use all the regular [Sandbox API](/sandbox/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 a code interpreter powered by an LLM.

- **Create sandbox**
<CodeGroup isRunnable={false}>
```js {{ language: 'js' }}
import { CodeInterpreter } from '@e2b/sdk'
const sandbox = await CodeInterpreter.create()

// Close sandbox once you're done
await sandbox.close()
```

```python {{ language: 'python' }}
from e2b import CodeInterpreter
sandbox = CodeInterpreter()

# Close sandbox once you're done
sandbox.close()
```
</CodeGroup>

- **Run Python code**
<CodeGroup isRunnable={false}>
```js {{ language: 'js' }}
import { CodeInterpreter } from '@e2b/sdk'

// 1. Create sandbox
const sandbox = await CodeInterpreter.create()

// 2. Get code that was generated by LLM and run it
const llmGeneratedPythonCode = 'print("Hello World")'
// `artifacts` are chart files created by matplotlib
const { stdout, stderr, artifacts } = await sandbox.runPython(llmGeneratedPythonCode)

// 3. Retrieve chart files:
for (const artifact of artifacts) {
  // Now you can save this file, send it to frontend, or anything else
  const downloadedChart = await artifact.download()
}

// 4. Close sandbox
await sandbox.close
```

```python {{ language: 'python' }}
from e2b import CodeInterpreter

# 1. Create sandbox
sandbox = CodeInterpreter()

# 2. Get code that was generated by LLM and run it
llm_generated_python_code = 'print("Hello World")'
# `artifacts` are chart files created by matplotlib
stdout, stderr, artifacts = sandbox.run_python(llm_generated_python_code)

# 3. Retrieve chart files:
for artifact in artifacts:
  # Now you can save this file, send it to frontend, or anything else
  downloaded_chart = artifact.download()

# 4. Close sandbox
sandbox.close()
```
</CodeGroup>

- **Install Python packages**

Installs Python packages using `pip`.
<CodeGroup isRunnable={false}>
```js {{ language: 'js' }}
import { CodeInterpreter } from '@e2b/sdk'

// 1. Create sandbox
const sandbox = await CodeInterpreter.create()

// 2. Install Python package
await CodeInterpreter.installPythonPackages('ffmpeg')

// 3. Close sandbox
await sandbox.close()
```
```python {{ language: 'python' }}
from e2b import CodeInterpreter

# 1. Create sandbox
sandbox = CodeInterpreter()

# 2. Install Python package
sandbox.install_python_packages('ffmpeg')

# 3. Close sandbox
sandbox.close()
```
</CodeGroup>

- **Install system packages**

Installs system packages using `apt-get`.
<CodeGroup isRunnable={false}>
```js {{ language: 'js' }}
import { CodeInterpreter } from '@e2b/sdk'

// 1. Create sandbox
const sandbox = await CodeInterpreter.create()

// 2. Install system package
await CodeInterpreter.installSystemPackages('ffmpeg')

// 3. Close sandbox
await sandbox.close()
```
```python {{ language: 'python' }}
from e2b import CodeInterpreter

# 1. Create sandbox
sandbox = CodeInterpreter()

# 2. Install system package
sandbox.install_system_packages('ffmpeg')

# 3. Close sandbox
sandbox.close()
```
</CodeGroup>

{/* - Listen to new files generated by executed code (charts, images, etc)
<CodeGroup isRunnable={false}>
```js {{ language: 'js' }}
await CodeInterpreter.installSystemPackages('ffmpeg')
await sandbox.close()
```
```python {{ language: 'python' }}
sandbox = CodeInterpreter.install_system_packages('ffmpeg')
sandbox.close()
```
</CodeGroup> */}

{/* - Stream code output
- Stream code errors
- Upload file
- Download file */}


