Skip to content

Commit c607f77

Browse files
authored
Merge pull request #882 from tyfiero/Add-safety-and-docker-support-documentation
2 parents 665593f + a3f6834 commit c607f77

File tree

6 files changed

+168
-11
lines changed

6 files changed

+168
-11
lines changed

docs/integrations/docker.mdx

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,68 @@
22
title: Docker
33
---
44

5-
Coming soon...
5+
Docker support is currently experimental. Running Open Interpreter inside of a Docker container can cause issues, and it may not function as you expect. Let us know on [Discord](https://discord.com/invite/6p3fD6rBVm) if you encounter errors or have suggestions to improve Docker support. We are working on an official integration for Docker in the coming weeks. For now, you can use Open Interpreter in a sandboxed Docker container environment using the following steps:
6+
7+
1. If you do not have Docker Desktop installed, [install it](https://www.docker.com/products/docker-desktop) before proceeding.
8+
9+
2. Create a new directory and add a file named `Dockerfile` in it with the following contents:
10+
11+
```dockerfile
12+
# Use an official Python runtime as a parent image
13+
FROM python:3.11
14+
# Set the working directory in the container to /app
15+
WORKDIR /app
16+
# Copy the current directory contents into the container at /app
17+
COPY . /app
18+
# Install any needed packages specified in requirements.txt
19+
RUN pip install --no-cache-dir -r requirements.txt
20+
21+
```
22+
23+
3. Create a file named `requirements.txt` in the same directory with the following contents:
24+
25+
```text
26+
open-interpreter
27+
```
28+
29+
4. Create a file named docker-compose.yml in the same directory with the following contents:
30+
31+
```yaml
32+
version: "3"
33+
services:
34+
oi:
35+
build: .
36+
volumes:
37+
- .:/app
38+
tty: true
39+
environment:
40+
- OPENAI_API_KEY=<your-openai-api-key>
41+
```
42+
43+
5. Run the following command in the same directory to start Open Interpreter. The `-rm` flag ensures that the container is removed after the command is executed.
44+
45+
```bash
46+
47+
docker-compose run --rm oi interpreter
48+
49+
```
50+
51+
To add flags to the command, just append them after `interpreter`. For example, to run the interpreter with custom instructions, run the following command:
52+
53+
```bash
54+
55+
docker-compose run --rm oi interpreter --custom_instructions "Be as concise as possible"
56+
57+
```
58+
59+
Please note that some flags will not work. For example, `--config` will not work, because it cannot open the config file in the container. If you want to use a config file other than the default, you can create a `config.yml` file inside of the same directory, add your custom config, and then run the following command:
60+
61+
```bash
62+
63+
docker-compose run --rm oi interpreter --config_file config.yml
64+
65+
```
66+
67+
Also keep in mind that when it runs inside a docker container, it is sandboxed from your machine. That means it does NOT have access to any of your files, nor will it know what operating system you are using, as it will be running a Linux OS inside the container. You can add files directly to the directory that contains the `Dockerfile` and `docker-compose.yml` files if you need to.
68+
69+
Again, we are working on an official integration for Docker in the coming weeks. Please let us know if you have any ideas on how to make it better!

docs/safety/best-practices.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@
22
title: Best Practices
33
---
44

5-
Coming soon...
5+
LLM's are not perfect. They can make mistakes, they can be tricked into doing things that they shouldn't, and they are capable of writing unsafe code. This page will help you understand how to use these LLM's safely.
6+
7+
## Best Practices
8+
9+
- Avoid asking it to perform potentially risky tasks. This seems obvious, but it's the number one way to prevent safety mishaps.
10+
11+
- Run it in a sandbox. This is the safest way to run it, as it completely isolates the code it runs from the rest of your system.
12+
13+
- Use trusted models. Yes, Open Interpreter can be configured to run pretty much any text-based model on huggingface. But it does not mean it's a good idea to run any random model you find. Make sure you trust the models you're using. If you're not sure, run it in a sandbox. Nefarious LLM's are becoming a real problem, and they are not going away anytime soon.
14+
15+
- Local models are fun! But GPT-4 is probably your safest bet. OpenAI has their models aligned in a major way. It will outperform the local models, and it will generally refuse to run unsafe code, as it truly understands that the code it writes could be run. It has a pretty good idea what unsafe code looks like, and will refuse to run code like `rm -rf /` that would delete your entire disk, for example.
16+
17+
- The [--safe_mode](/safety/safe-mode) argument is your friend. It enables code scanning, and can use [guarddog](https://github.com/DataDog/guarddog) to identify malicious PyPi and npm packages. It's not a perfect solution, but it's a great start.

docs/safety/introduction.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@
22
title: Introduction
33
---
44

5-
Coming soon...
5+
Safety is a top priority for us at Open Interpreter. Running LLM generated code on your computer is inherently risky, and we have taken steps to make it as safe as possible. One of the primary safety 'mechanisms', is the alignment of the LLM itself. GPT-4 refuses to run dangerous code like `rm -rf /`, it understands what that command will do, and won't let you footgun yourself. This is less applicable when running local models like Mistral, that have little or no alignment, making our other safety measures more important.
6+
7+
# Safety Measures
8+
9+
- [Safe mode]("/safety/safe-mode.mdx") enables code scanning, as well as the ability to scan packages with (guarddog)[https://github.com/DataDog/guarddog] with a simple change to the system message. See the [safe mode docs](/safety/safe-mode.mdx) for more information.
10+
11+
- Requiring confirmation with the user before the code is actually run. This is a simple measure that can prevent a lot of accidents. It exists as another layer of protection, but can be disabled with the `--auto-run` flag if you wish.
12+
13+
- Sandboxing code execution. Open Interpreter can be run in a sandboxed envirnoment using [Docker](/introduction/docker). This is a great way to run code without worrying about it affecting your system. Docker support is currently experimental, but we are working on making it a core feature of Open Interpreter. Another option for sandboxing is [E2B](https://e2b.dev/), which overrides the default python language with a sandboxed, hosted version of python through E2B. Follow [this guide](/introduction/e2b) to set it up.
14+
15+
## Notice
16+
17+
Open Interpreter is not responsible for any damage caused by using the package. These safety measures provide no guarantees of safety or security. Please be careful when running code generated by Open Interpreter, and make sure you understand what it will do before running it.

docs/safety/isolation.mdx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@
22
title: Isolation
33
---
44

5-
Coming soon...
5+
Isolating Open Interpreter from your system is helpful to prevent security mishaps. By running it in a separate process, you can ensure that actions taken by Open Interpreter will not directly affect your system. This is by far the safest way to run Open Interpreter, although it can be limiting based on your use case.
6+
7+
If you wish to sandbox Open Interpreter, we have two primary methods of doing so: Docker and E2B.
8+
9+
## Docker
10+
11+
Docker is a containerization technology that allows you to run an isolated Linux environment on your system. This allows you to run Open Interpreter in a container, which **completely** isolates it from your system. All code execution is done in the container, and the container is not able to access your system. Docker support is currently experimental, and we are working on integrating it as a core feature of Open Interpreter.
12+
13+
Follow [these instructions](/integrations/docker) to get it running.
14+
15+
## E2B
16+
17+
[E2B](https://e2b.dev/) is a cloud-based platform for running sandboxed code environments, designed for use by AI agents. You can override the default `python` language in Open Interpreter to use E2B, and it will automatically run the code in a cloud-sandboxed environment. You will need an E2B account to use this feature. It's worth noting that this will only sandbox python code, other languages like shell and JavaScript will still be run on your system.
18+
19+
Follow [these instructions](/integrations/e2b) to get it running.

docs/safety/safe-mode.mdx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,63 @@
22
title: Safe Mode
33
---
44

5-
Coming soon...
5+
# Safe Mode
6+
7+
**⚠️ Safe mode is experimental and does not provide any guarantees of safety or security.**
8+
9+
Open Interpreter is working on providing an experimental safety toolkit to help you feel more confident running the code generated by Open Interpreter.
10+
11+
Install Open Interpreter with the safety toolkit dependencies as part of the bundle:
12+
13+
```shell
14+
pip install open-interpreter[safe]
15+
```
16+
17+
Alternatively, you can install the safety toolkit dependencies separately in your virtual environment:
18+
19+
```shell
20+
pip install semgrep
21+
```
22+
23+
## Features
24+
25+
- **No Auto Run**: Safe mode disables the ability to automatically execute code
26+
- **Code Scanning**: Scan generated code for vulnerabilities with [`semgrep`](https://semgrep.dev/)
27+
28+
## Enabling Safe Mode
29+
30+
You can enable safe mode by passing the `--safe` flag when invoking `interpreter` or by configuring `safe_mode` in your [config file](https://github.com/KillianLucas/open-interpreter#configuration).
31+
32+
The safe mode setting has three options:
33+
34+
- `off`: disables the safety toolkit (_default_)
35+
- `ask`: prompts you to confirm that you want to scan code
36+
- `auto`: automatically scans code
37+
38+
### Example Config:
39+
40+
```yaml
41+
model: gpt-4
42+
temperature: 0
43+
verbose: false
44+
safe_mode: ask
45+
```
46+
47+
## Roadmap
48+
49+
Some upcoming features that enable even more safety:
50+
51+
- [Execute code in containers](https://github.com/KillianLucas/open-interpreter/pull/459)
52+
53+
## Tips & Tricks
54+
55+
You can adjust the `custom_instructions` in your [config file](https://github.com/KillianLucas/open-interpreter#configuration) to include instructions for the model to scan packages with [guarddog](https://github.com/DataDog/guarddog) before installing them.
56+
57+
```yaml
58+
model: gpt-4
59+
verbose: false
60+
safe_mode: ask
61+
system_message: |
62+
# normal system message here
63+
BEFORE INSTALLING ANY PACKAGES WITH pip OR npm YOU MUST SCAN THEM WITH `guarddog` FIRST. Run `guarddog pypi scan $package` for pip packages and `guarddog npm scan $package` for npm packages. `guarddog` only accepts one package name at a time.
64+
```

docs/usage/terminal/arguments.mdx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fast: true
9494

9595
#### `--local` or `-l`
9696

97-
Run the model locally. Check the [local mode page](/language-model-setup/local-models/overview) for more information.
97+
Run the model locally. Check the [models page](/language-model-setup/introduction) for more information.
9898

9999
<CodeGroup>
100100

@@ -416,11 +416,7 @@ speak_messages: true
416416

417417
Get the current installed version number of Open Interpreter.
418418

419-
<CodeGroup>
420-
```bash Terminal
421-
interpreter --version
422-
```
423-
</CodeGroup>
419+
<CodeGroup>```bash Terminal interpreter --version ```</CodeGroup>
424420

425421
#### `--help` or `-h`
426422

0 commit comments

Comments
 (0)