Spaces:
Running
on
Zero
Running
on
Zero
File size: 14,769 Bytes
4549941 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
<h1 align="center">● Open Interpreter</h1>
<p align="center">
<a href="https://discord.gg/Hvz9Axh84z">
<img alt="Discord" src="https://img.shields.io/discord/1146610656779440188?logo=discord&style=flat&logoColor=white"/></a>
<a href="https://github.com/OpenInterpreter/open-interpreter/blob/main/docs/README_JA.md"><img src="https://img.shields.io/badge/ドキュメント-日本語-white.svg" alt="JA doc"/></a>
<a href="https://github.com/OpenInterpreter/open-interpreter/blob/main/docs/README_ZH.md"><img src="https://img.shields.io/badge/文档-中文版-white.svg" alt="ZH doc"/></a>
<a href="https://github.com/OpenInterpreter/open-interpreter/blob/main/docs/README_ES.md"> <img src="https://img.shields.io/badge/Español-white.svg" alt="ES doc"/></a>
<a href="https://github.com/OpenInterpreter/open-interpreter/blob/main/docs/README_IN.md"><img src="https://img.shields.io/badge/Hindi-white.svg" alt="IN doc"/></a>
<a href="https://github.com/OpenInterpreter/open-interpreter/blob/main/LICENSE"><img src="https://img.shields.io/static/v1?label=license&message=AGPL&color=white&style=flat" alt="License"/></a>
<br>
<br>
<br><a href="https://0ggfznkwh4j.typeform.com/to/G21i9lJ2">Get early access to the desktop app</a> | <a href="https://docs.openinterpreter.com/">Documentation</a><br>
</p>
<br>
![poster](https://github.com/KillianLucas/open-interpreter/assets/63927363/08f0d493-956b-4d49-982e-67d4b20c4b56)
<br>
<p align="center">
<strong>The New Computer Update</strong> introduced <strong><code>--os</code></strong> and a new <strong>Computer API</strong>. <a href="https://changes.openinterpreter.com/log/the-new-computer-update">Read On →</a>
</p>
<br>
```shell
pip install open-interpreter
```
> Not working? Read our [setup guide](https://docs.openinterpreter.com/getting-started/setup).
```shell
interpreter
```
<br>
**Open Interpreter** lets LLMs run code (Python, Javascript, Shell, and more) locally. You can chat with Open Interpreter through a ChatGPT-like interface in your terminal by running `$ interpreter` after installing.
This provides a natural-language interface to your computer's general-purpose capabilities:
- Create and edit photos, videos, PDFs, etc.
- Control a Chrome browser to perform research
- Plot, clean, and analyze large datasets
- ...etc.
**⚠️ Note: You'll be asked to approve code before it's run.**
<br>
## Demo
https://github.com/KillianLucas/open-interpreter/assets/63927363/37152071-680d-4423-9af3-64836a6f7b60
#### An interactive demo is also available on Google Colab:
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1WKmRXZgsErej2xUriKzxrEAXdxMSgWbb?usp=sharing)
#### Along with an example voice interface, inspired by _Her_:
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1NojYGHDgxH6Y1G1oxThEBBb2AtyODBIK)
## Quick Start
```shell
pip install open-interpreter
```
### Terminal
After installation, simply run `interpreter`:
```shell
interpreter
```
### Python
```python
from interpreter import interpreter
interpreter.chat("Plot AAPL and META's normalized stock prices") # Executes a single command
interpreter.chat() # Starts an interactive chat
```
### GitHub Codespaces
Press the `,` key on this repository's GitHub page to create a codespace. After a moment, you'll receive a cloud virtual machine environment pre-installed with open-interpreter. You can then start interacting with it directly and freely confirm its execution of system commands without worrying about damaging the system.
## Comparison to ChatGPT's Code Interpreter
OpenAI's release of [Code Interpreter](https://openai.com/blog/chatgpt-plugins#code-interpreter) with GPT-4 presents a fantastic opportunity to accomplish real-world tasks with ChatGPT.
However, OpenAI's service is hosted, closed-source, and heavily restricted:
- No internet access.
- [Limited set of pre-installed packages](https://wfhbrian.com/mastering-chatgpts-code-interpreter-list-of-python-packages/).
- 100 MB maximum upload, 120.0 second runtime limit.
- State is cleared (along with any generated files or links) when the environment dies.
---
Open Interpreter overcomes these limitations by running in your local environment. It has full access to the internet, isn't restricted by time or file size, and can utilize any package or library.
This combines the power of GPT-4's Code Interpreter with the flexibility of your local development environment.
## Commands
**Update:** The Generator Update (0.1.5) introduced streaming:
```python
message = "What operating system are we on?"
for chunk in interpreter.chat(message, display=False, stream=True):
print(chunk)
```
### Interactive Chat
To start an interactive chat in your terminal, either run `interpreter` from the command line:
```shell
interpreter
```
Or `interpreter.chat()` from a .py file:
```python
interpreter.chat()
```
**You can also stream each chunk:**
```python
message = "What operating system are we on?"
for chunk in interpreter.chat(message, display=False, stream=True):
print(chunk)
```
### Programmatic Chat
For more precise control, you can pass messages directly to `.chat(message)`:
```python
interpreter.chat("Add subtitles to all videos in /videos.")
# ... Streams output to your terminal, completes task ...
interpreter.chat("These look great but can you make the subtitles bigger?")
# ...
```
### Start a New Chat
In Python, Open Interpreter remembers conversation history. If you want to start fresh, you can reset it:
```python
interpreter.messages = []
```
### Save and Restore Chats
`interpreter.chat()` returns a List of messages, which can be used to resume a conversation with `interpreter.messages = messages`:
```python
messages = interpreter.chat("My name is Killian.") # Save messages to 'messages'
interpreter.messages = [] # Reset interpreter ("Killian" will be forgotten)
interpreter.messages = messages # Resume chat from 'messages' ("Killian" will be remembered)
```
### Customize System Message
You can inspect and configure Open Interpreter's system message to extend its functionality, modify permissions, or give it more context.
```python
interpreter.system_message += """
Run shell commands with -y so the user doesn't have to confirm them.
"""
print(interpreter.system_message)
```
### Change your Language Model
Open Interpreter uses [LiteLLM](https://docs.litellm.ai/docs/providers/) to connect to hosted language models.
You can change the model by setting the model parameter:
```shell
interpreter --model gpt-3.5-turbo
interpreter --model claude-2
interpreter --model command-nightly
```
In Python, set the model on the object:
```python
interpreter.llm.model = "gpt-3.5-turbo"
```
[Find the appropriate "model" string for your language model here.](https://docs.litellm.ai/docs/providers/)
### Running Open Interpreter locally
#### Terminal
Open Interpreter can use OpenAI-compatible server to run models locally. (LM Studio, jan.ai, ollama etc)
Simply run `interpreter` with the api_base URL of your inference server (for LM studio it is `http://localhost:1234/v1` by default):
```shell
interpreter --api_base "http://localhost:1234/v1" --api_key "fake_key"
```
Alternatively you can use Llamafile without installing any third party software just by running
```shell
interpreter --local
```
for a more detailed guide check out [this video by Mike Bird](https://www.youtube.com/watch?v=CEs51hGWuGU?si=cN7f6QhfT4edfG5H)
**How to run LM Studio in the background.**
1. Download [https://lmstudio.ai/](https://lmstudio.ai/) then start it.
2. Select a model then click **↓ Download**.
3. Click the **↔️** button on the left (below 💬).
4. Select your model at the top, then click **Start Server**.
Once the server is running, you can begin your conversation with Open Interpreter.
> **Note:** Local mode sets your `context_window` to 3000, and your `max_tokens` to 1000. If your model has different requirements, set these parameters manually (see below).
#### Python
Our Python package gives you more control over each setting. To replicate and connect to LM Studio, use these settings:
```python
from interpreter import interpreter
interpreter.offline = True # Disables online features like Open Procedures
interpreter.llm.model = "openai/x" # Tells OI to send messages in OpenAI's format
interpreter.llm.api_key = "fake_key" # LiteLLM, which we use to talk to LM Studio, requires this
interpreter.llm.api_base = "http://localhost:1234/v1" # Point this at any OpenAI compatible server
interpreter.chat()
```
#### Context Window, Max Tokens
You can modify the `max_tokens` and `context_window` (in tokens) of locally running models.
For local mode, smaller context windows will use less RAM, so we recommend trying a much shorter window (~1000) if it's failing / if it's slow. Make sure `max_tokens` is less than `context_window`.
```shell
interpreter --local --max_tokens 1000 --context_window 3000
```
### Verbose mode
To help you inspect Open Interpreter we have a `--verbose` mode for debugging.
You can activate verbose mode by using its flag (`interpreter --verbose`), or mid-chat:
```shell
$ interpreter
...
> %verbose true <- Turns on verbose mode
> %verbose false <- Turns off verbose mode
```
### Interactive Mode Commands
In the interactive mode, you can use the below commands to enhance your experience. Here's a list of available commands:
**Available Commands:**
- `%verbose [true/false]`: Toggle verbose mode. Without arguments or with `true` it
enters verbose mode. With `false` it exits verbose mode.
- `%reset`: Resets the current session's conversation.
- `%undo`: Removes the previous user message and the AI's response from the message history.
- `%tokens [prompt]`: (_Experimental_) Calculate the tokens that will be sent with the next prompt as context and estimate their cost. Optionally calculate the tokens and estimated cost of a `prompt` if one is provided. Relies on [LiteLLM's `cost_per_token()` method](https://docs.litellm.ai/docs/completion/token_usage#2-cost_per_token) for estimated costs.
- `%help`: Show the help message.
### Configuration / Profiles
Open Interpreter allows you to set default behaviors using `yaml` files.
This provides a flexible way to configure the interpreter without changing command-line arguments every time.
Run the following command to open the profiles directory:
```
interpreter --profiles
```
You can add `yaml` files there. The default profile is named `default.yaml`.
#### Multiple Profiles
Open Interpreter supports multiple `yaml` files, allowing you to easily switch between configurations:
```
interpreter --profile my_profile.yaml
```
## Sample FastAPI Server
The generator update enables Open Interpreter to be controlled via HTTP REST endpoints:
```python
# server.py
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from interpreter import interpreter
app = FastAPI()
@app.get("/chat")
def chat_endpoint(message: str):
def event_stream():
for result in interpreter.chat(message, stream=True):
yield f"data: {result}\n\n"
return StreamingResponse(event_stream(), media_type="text/event-stream")
@app.get("/history")
def history_endpoint():
return interpreter.messages
```
```shell
pip install fastapi uvicorn
uvicorn server:app --reload
```
You can also start a server identical to the one above by simply running `interpreter.server()`.
## Android
The step-by-step guide for installing Open Interpreter on your Android device can be found in the [open-interpreter-termux repo](https://github.com/MikeBirdTech/open-interpreter-termux).
## Safety Notice
Since generated code is executed in your local environment, it can interact with your files and system settings, potentially leading to unexpected outcomes like data loss or security risks.
**⚠️ Open Interpreter will ask for user confirmation before executing code.**
You can run `interpreter -y` or set `interpreter.auto_run = True` to bypass this confirmation, in which case:
- Be cautious when requesting commands that modify files or system settings.
- Watch Open Interpreter like a self-driving car, and be prepared to end the process by closing your terminal.
- Consider running Open Interpreter in a restricted environment like Google Colab or Replit. These environments are more isolated, reducing the risks of executing arbitrary code.
There is **experimental** support for a [safe mode](https://github.com/OpenInterpreter/open-interpreter/blob/main/docs/SAFE_MODE.md) to help mitigate some risks.
## How Does it Work?
Open Interpreter equips a [function-calling language model](https://platform.openai.com/docs/guides/gpt/function-calling) with an `exec()` function, which accepts a `language` (like "Python" or "JavaScript") and `code` to run.
We then stream the model's messages, code, and your system's outputs to the terminal as Markdown.
# Access Documentation Offline
The full [documentation](https://docs.openinterpreter.com/) is accessible on-the-go without the need for an internet connection.
[Node](https://nodejs.org/en) is a pre-requisite:
- Version 18.17.0 or any later 18.x.x version.
- Version 20.3.0 or any later 20.x.x version.
- Any version starting from 21.0.0 onwards, with no upper limit specified.
Install [Mintlify](https://mintlify.com/):
```bash
npm i -g mintlify@latest
```
Change into the docs directory and run the appropriate command:
```bash
# Assuming you're at the project's root directory
cd ./docs
# Run the documentation server
mintlify dev
```
A new browser window should open. The documentation will be available at [http://localhost:3000](http://localhost:3000) as long as the documentation server is running.
# Contributing
Thank you for your interest in contributing! We welcome involvement from the community.
Please see our [contributing guidelines](https://github.com/OpenInterpreter/open-interpreter/blob/main/docs/CONTRIBUTING.md) for more details on how to get involved.
# Roadmap
Visit [our roadmap](https://github.com/KillianLucas/open-interpreter/blob/main/docs/ROADMAP.md) to preview the future of Open Interpreter.
**Note**: This software is not affiliated with OpenAI.
![thumbnail-ncu](https://github.com/KillianLucas/open-interpreter/assets/63927363/1b19a5db-b486-41fd-a7a1-fe2028031686)
> Having access to a junior programmer working at the speed of your fingertips ... can make new workflows effortless and efficient, as well as open the benefits of programming to new audiences.
>
> — _OpenAI's Code Interpreter Release_
<br>
|