### JARVIS Interface Setup Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/JARVIS.ipynb Provides setup instructions for the JARVIS interface. Users are guided to run the cell, scroll down, record audio, and submit commands, with a note on the interface loading time. ```markdown # @title JARVIS # @markdown ### **Setup Instructions** # @markdown 1. Run this cell, then scroll down to use the interface (don't click the link, and **give the interface 60 seconds to load**). # @markdown 2. Press the `Record from Microphone` button. # @markdown 3. Allow access to your microphone, then speak your command. # @markdown 4. Stop the recording, then press `Submit`. # @markdown # @markdown ``` -------------------------------- ### Install Mintlify for Offline Documentation Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md Commands to install Mintlify globally using npm and start the local documentation server. Node.js version 18.17.0 or later, or 20.3.0 or later, or any version from 21.0.0 onwards is required. ```bash npm i -g mintlify@latest ``` ```bash # Assuming you're at the project's root directory cd ./docs # Run the documentation server mintlify dev ``` -------------------------------- ### Start Server Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md Starts the Open Interpreter server with default settings. ```APIDOC ## Run Server ### Description Starts an HTTP server that exposes the Open Interpreter API. ### Command ```bash interpreter.server() ``` ``` -------------------------------- ### Install open-interpreter Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/JARVIS.ipynb Run this command to install the open-interpreter package. A runtime restart is required after installation. ```python !pip install open-interpreter ``` -------------------------------- ### Pre-configure Interpreter with Imports and API Keys Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/usage.mdx Before starting a chat, you can run code to import libraries or log in to services. This ensures the AI has the necessary setup. ```python interpreter.computer.run("python", "import replicate\nreplicate.api_key='...'" ) ``` ```python interpreter.custom_instructions = "Replicate has already been imported." interpreter.chat("Please generate an image on replicate...") ``` -------------------------------- ### Install Replicate and Set API Token Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/Open_Interpreter_Demo.ipynb Installs the Replicate library and sets the REPLICATE_API_TOKEN environment variable. Obtain your API token from the Replicate website. ```python !pip install replicate import os os.environ["REPLICATE_API_TOKEN"] = "api_token" # Get yours: https://replicate.com/account ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/CONTRIBUTING.md Install the pre-commit framework and its hooks to automatically format code upon committing. ```bash pip install pre-commit pre-commit install ``` -------------------------------- ### Install Optional Dependencies for Local/OS Modes Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/CONTRIBUTING.md When running `poetry install`, optional dependencies for specific modes like `--local` or `--os` are not included by default. Use these commands to install them. ```bash poetry install -E local ``` ```bash poetry install -E os ``` ```bash poetry install -E local -E os ``` -------------------------------- ### Starting the Server Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Instructions on how to initiate the Open Interpreter server, both from the command line and within a Python script. ```bash interpreter --server ``` ```python from interpreter import AsyncInterpreter async_interpreter = AsyncInterpreter() async_interpreter.server.run(port=8000) ``` -------------------------------- ### Install Petals Library Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/petals.mdx Install the Petals library using pip to enable integration with Open Interpreter. ```bash pip install git+https://github.com/bigscience-workshop/petals ``` -------------------------------- ### Install Open Interpreter on Linux using curl Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/setup.mdx This experimental installer attempts to download Python, set up an environment, and install Open Interpreter for you on Linux. Run with admin privileges. ```bash curl -sL https://raw.githubusercontent.com/openinterpreter/open-interpreter/main/installers/oi-linux-installer.sh | bash ``` -------------------------------- ### List Supported Cohere Models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/cohere.mdx Examples of setting various Cohere models using the CLI. ```bash interpreter --model command interpreter --model command-light interpreter --model command-medium interpreter --model command-medium-beta interpreter --model command-xlarge-beta interpreter --model command-nightly ``` -------------------------------- ### Install Open Interpreter on Windows using PowerShell Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/setup.mdx This experimental installer attempts to download Python, set up an environment, and install Open Interpreter for you on Windows using PowerShell. Run with admin privileges. ```powershell iex "& {$(irm https://raw.githubusercontent.com/openinterpreter/open-interpreter/main/installers/oi-windows-installer-conda.ps1)}" ``` -------------------------------- ### List of Supported OpenRouter Models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/openrouter.mdx Examples of how to set various OpenRouter models via CLI and Python. ```bash interpreter --model openrouter/openai/gpt-3.5-turbo interpreter --model openrouter/openai/gpt-3.5-turbo-16k interpreter --model openrouter/openai/gpt-4 interpreter --model openrouter/openai/gpt-4-32k interpreter --model openrouter/anthropic/claude-2 interpreter --model openrouter/anthropic/claude-instant-v1 interpreter --model openrouter/google/palm-2-chat-bison interpreter --model openrouter/google/palm-2-codechat-bison interpreter --model openrouter/meta-llama/llama-2-13b-chat interpreter --model openrouter/meta-llama/llama-2-70b-chat ``` ```python interpreter.llm.model = "openrouter/openai/gpt-3.5-turbo" interpreter.llm.model = "openrouter/openai/gpt-3.5-turbo-16k" interpreter.llm.model = "openrouter/openai/gpt-4" interpreter.llm.model = "openrouter/openai/gpt-4-32k" interpreter.llm.model = "openrouter/anthropic/claude-2" interpreter.llm.model = "openrouter/anthropic/claude-instant-v1" interpreter.llm.model = "openrouter/google/palm-2-chat-bison" interpreter.llm.model = "openrouter/google/palm-2-codechat-bison" interpreter.llm.model = "openrouter/meta-llama/llama-2-13b-chat" interpreter.llm.model = "openrouter/meta-llama/llama-2-70b-chat" ``` -------------------------------- ### Start Llama3 Server and Run Open Interpreter Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/local3.ipynb Starts the Llama3 llamafile as a subprocess and runs Open Interpreter's chat interface. Output from the server is printed in real-time. ```python import subprocess import threading import os def read_output(process): while True: output = process.stdout.readline() if output == b'' and process.poll() is not None: break if output: print(output.decode().strip()) # Check if the file exists and has execute permissions file_path = os.path.abspath('Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile') # Why are the arguments not being used?? command = [file_path, "--nobrowser", "-ngl", "9999"] print(command) # Setting up the Popen call with stderr redirected to stdout process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) # Thread to handle the output asynchronously thread = threading.Thread(target=read_output, args=(process,)) thread.start() # Here you can do other tasks concurrently # For example: interpreter.chat() # Wait for the thread to finish if the process completes thread.join() # Ensure the process has completed process.wait() ``` -------------------------------- ### Install Open Interpreter with Pip Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/introduction.mdx Install the Open Interpreter package using pip. This is the recommended method for users who already have Python installed. ```bash pip install open-interpreter ``` -------------------------------- ### Install Open Interpreter with OS Mode dependencies Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/setup.mdx Install Open Interpreter with dependencies for OS Mode, which allows the interpreter to interact with your operating system. Refer to the OS Mode guide for more details. ```bash pip install open-interpreter[os] ``` -------------------------------- ### Download and Run LlamaFile Model Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/local-models/llamafile.mdx Download a LlamaFile model, make it executable, and start the server. Then, configure Open Interpreter to use the local server. ```bash # Download Mixtral wget https://huggingface.co/jartine/Mixtral-8x7B-v0.1.llamafile/resolve/main/mixtral-8x7b-instruct-v0.1.Q5_K_M-server.llamafile # Make it an executable chmod +x mixtral-8x7b-instruct-v0.1.Q5_K_M-server.llamafile # Start the server ./mixtral-8x7b-instruct-v0.1.Q5_K_M-server.llamafile # In a separate terminal window, run OI and point it at the llamafile server interpreter --api_base https://localhost:8080/v1 ``` -------------------------------- ### Install Open Interpreter and OpenCV Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/local3.ipynb Installs the Open Interpreter library and OpenCV for Python. Use --quiet to suppress verbose output. ```python !pip install open-interpreter --quiet !pip install opencv-python --quiet ``` -------------------------------- ### List Supported Petals Models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/petals.mdx Examples of how to specify different Petals models via the CLI and Python API. ```bash interpreter --model petals/petals-team/StableBeluga2 interpreter --model petals/huggyllama/llama-65b ``` ```python interpreter.llm.model = "petals/petals-team/StableBeluga2" interpreter.llm.model = "petals/huggyllama/llama-65b" ``` -------------------------------- ### Install Open Interpreter via pip Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md Install the Open Interpreter package from its GitHub repository using pip. Ensure you have Python and pip installed. ```shell pip install git+https://github.com/OpenInterpreter/open-interpreter.git ``` -------------------------------- ### Install Developer Dependencies Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/CONTRIBUTING.md For installing dependencies specifically for development, such as testing or formatting tools, use the `--group dev` flag with `poetry add`. ```bash poetry add package-name --group dev ``` -------------------------------- ### Install Open Interpreter on Mac using curl Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/setup.mdx This experimental installer attempts to download Python, set up an environment, and install Open Interpreter for you on macOS. Run with admin privileges. ```bash curl -sL https://raw.githubusercontent.com/openinterpreter/open-interpreter/main/installers/oi-mac-installer.sh | bash ``` -------------------------------- ### Install Open Interpreter Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/Open_Interpreter_Demo.ipynb Installs the open-interpreter package. Google Colab users should restart their runtime after installation. ```python !pip install open-interpreter # Google Colab users: restart your runtime here. ``` -------------------------------- ### Install Open Interpreter with Server dependencies Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/setup.mdx Install Open Interpreter with dependencies needed for server-related functionalities. This is typically used when running Open Interpreter as a backend service. ```bash pip install open-interpreter[server] ``` -------------------------------- ### Install New Project Dependencies Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/CONTRIBUTING.md When adding new packages to the project, use `poetry add` to manage dependencies within the virtual environment. ```bash poetry add package-name ``` -------------------------------- ### Install Open Interpreter with Safety Toolkit Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/SAFE_MODE.md Install Open Interpreter including the safety toolkit dependencies as part of the bundle. ```shell pip install open-interpreter[safe] ``` -------------------------------- ### Install Python Packages for Open Interpreter Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/JARVIS.ipynb Installs Whisper, Gradio, and ElevenLabs using pip. Run this command in your environment before using Open Interpreter. ```python !pip install git+https://github.com/openai/whisper.git -q !pip install gradio==3.50 -q !pip install elevenlabs -q ``` -------------------------------- ### Install pychrome Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/ROADMAP.md Installs the pychrome library, which is required for interacting with a running Chrome instance via its debugging protocol. ```bash pip install pychrome ``` -------------------------------- ### Set Profile Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Use the `--profile` argument to specify which profile to use. An example using 'default.yaml' is shown. ```bash interpreter --profile "default.yaml" ``` -------------------------------- ### List Supported Anthropic Models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/anthropic.mdx Examples of setting different Anthropic model versions via the command line and Python. ```bash interpreter --model claude-instant-1 interpreter --model claude-instant-1.2 interpreter --model claude-2 ``` ```python interpreter.llm.model = "claude-instant-1" interpreter.llm.model = "claude-instant-1.2" interpreter.llm.model = "claude-2" ``` -------------------------------- ### Install OpenAI Python Package Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/gpt-4-setup.mdx Use this command to install the official OpenAI Python library, which is required for interacting with the API. ```bash pip install openai ``` -------------------------------- ### Install Open Interpreter with Local Mode dependencies Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/setup.mdx Install Open Interpreter with dependencies required for running locally. This enables features that do not require an internet connection. ```bash pip install open-interpreter[local] ``` -------------------------------- ### Create a Custom Profile Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/settings/profiles.mdx Define custom settings for Open Interpreter by creating a `.yaml` file in the profiles directory. This example sets custom instructions and specifies the LLM model and temperature. ```yaml custom_instructions: "Always use python, and be as concise as possible" llm.model: gpt-4 llm.temperature: 0.5 # Any other settings you'd like to add ``` -------------------------------- ### Install Safety Toolkit Dependencies Separately Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/SAFE_MODE.md Alternatively, install the safety toolkit dependencies separately in your virtual environment. ```shell pip install semgrep ``` -------------------------------- ### Start Server from Python Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Initiate the Open Interpreter server programmatically within a Python script. The default port is 8000, but it can be customized. ```python from interpreter import AsyncInterpreter async_interpreter = AsyncInterpreter() async_interpreter.server.run(port=8000) ``` -------------------------------- ### Use specific Baseten models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/baseten.mdx Examples of how to specify supported Baseten models like Falcon 7b, Wizard LM, and MPT 7b Base using their respective IDs in the terminal or Python configuration. ```bash interpreter --model baseten/qvv0xeq interpreter --model baseten/q841o8w interpreter --model baseten/31dxrj3 ``` ```python interpreter.llm.model = "baseten/qvv0xeq" interpreter.llm.model = "baseten/q841o8w" interpreter.llm.model = "baseten/31dxrj3" ``` -------------------------------- ### Run Open Interpreter with Ollama (Terminal) Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/local-models/ollama.mdx Start Open Interpreter in the terminal and configure it to use a local Ollama model. Replace `` with the downloaded model. ```bash interpreter --model ollama/ ``` -------------------------------- ### Use Specific Anyscale Models via CLI Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/anyscale.mdx Examples of setting specific Anyscale hosted models like Llama 2, Mistral, and CodeLlama using the CLI. ```bash interpreter --model anyscale/meta-llama/Llama-2-7b-chat-hf interpreter --model anyscale/meta-llama/Llama-2-13b-chat-hf interpreter --model anyscale/meta-llama/Llama-2-70b-chat-hf interpreter --model anyscale/mistralai/Mistral-7B-Instruct-v0.1 interpreter --model anyscale/codellama/CodeLlama-34b-Instruct-hf ``` -------------------------------- ### Download Llama3 Model Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/local3.ipynb Downloads the Meta-Llama-3-8B-Instruct.llamafile and makes it executable. Ensure you have curl installed. ```python # Download the Meta-Llama-3-8B-Instruct.llamafile !curl -L -o Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile 'https://huggingface.co/Mozilla/Meta-Llama-3-8B-Instruct-llamafile/resolve/main/Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile?download=true' # Make the downloaded file executable !chmod +x Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile ``` -------------------------------- ### Use Specific Anyscale Models via Python Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/anyscale.mdx Examples of setting specific Anyscale hosted models like Llama 2, Mistral, and CodeLlama using Python. ```python interpreter.llm.model = "anyscale/meta-llama/Llama-2-7b-chat-hf" interpreter.llm.model = "anyscale/meta-llama/Llama-2-13b-chat-hf" interpreter.llm.model = "anyscale/meta-llama/Llama-2-70b-chat-hf" interpreter.llm.model = "anyscale/mistralai/Mistral-7B-Instruct-v0.1" interpreter.llm.model = "anyscale/codellama/CodeLlama-34b-Instruct-hf" ``` -------------------------------- ### Build Docker Image for Open Interpreter Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/integrations/docker.mdx Create a Docker image with Python 3.11 and Open Interpreter installed. Replace `` with your actual API key. ```dockerfile # Start with Python 3.11 FROM python:3.11 # Replace with your own key ENV OPENAI_API_KEY # Install Open Interpreter RUN pip install open-interpreter ``` -------------------------------- ### Deploy Supported Sagemaker Models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/aws-sagemaker.mdx Examples of setting the model flag for various supported Llama 2 models and custom Huggingface deployments on Sagemaker. ```bash interpreter --model sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b interpreter --model sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b-f interpreter --model sagemaker/jumpstart-dft-meta-textgeneration-llama-2-13b interpreter --model sagemaker/jumpstart-dft-meta-textgeneration-llama-2-13b-f interpreter --model sagemaker/jumpstart-dft-meta-textgeneration-llama-2-70b interpreter --model sagemaker/jumpstart-dft-meta-textgeneration-llama-2-70b-b-f interpreter --model sagemaker/ ``` -------------------------------- ### WebSocket Interaction Example Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Demonstrates how to establish a WebSocket connection to the server and send multi-part messages, including text and image data, and how to receive and process responses. ```APIDOC ## WebSocket Interaction This example demonstrates the WebSocket interaction with the server. ### Method WebSocket ### Endpoint `ws://localhost:8000/` ### Request Example ```python import websockets import json import asyncio async def websocket_interaction(): async with websockets.connect("ws://localhost:8000/") as websocket: # Send a multi-part user message await websocket.send(json.dumps({"role": "user", "start": True})) await websocket.send(json.dumps({"role": "user", "type": "message", "content": "Analyze this image:"})) await websocket.send(json.dumps({"role": "user", "type": "image", "format": "path", "content": "path/to/image.jpg"})) await websocket.send(json.dumps({"role": "user", "end": True})) # Receive and process messages while True: message = await websocket.recv() data = json.loads(message) if data.get("type") == "message": print(f"Assistant: {data.get('content', '')}") elif data.get("type") == "review": print(f"Code Review: {data.get('content')}") elif data.get("type") == "error": print(f"Error: {data.get('content')}") elif data == {"role": "assistant", "type": "status", "content": "complete"}: print("Interaction complete") break asyncio.run(websocket_interaction()) ``` ### Response Handling Messages are received as JSON. The client should handle different message types such as `message`, `review`, `error`, and `complete` status. ``` -------------------------------- ### Run Open Interpreter CLI Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/CONTRIBUTING.md After setting up your local fork and installing dependencies, use this command to run the Open Interpreter in CLI mode. ```bash poetry run interpreter ``` -------------------------------- ### Use Specific DeepInfra Models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/deepinfra.mdx Examples of how to set specific supported models from DeepInfra using the command line or Python. ```bash interpreter --model deepinfra/meta-llama/Llama-2-70b-chat-hf interpreter --model deepinfra/meta-llama/Llama-2-7b-chat-hf interpreter --model deepinfra/meta-llama/Llama-2-13b-chat-hf interpreter --model deepinfra/codellama/CodeLlama-34b-Instruct-hf interpreter --model deepinfra/mistral/mistral-7b-instruct-v0.1 interpreter --model deepinfra/jondurbin/airoboros-l2-70b-gpt4-1.4.1 ``` ```python interpreter.llm.model = "deepinfra/meta-llama/Llama-2-70b-chat-hf" interpreter.llm.model = "deepinfra/meta-llama/Llama-2-7b-chat-hf" interpreter.llm.model = "deepinfra/meta-llama/Llama-2-13b-chat-hf" interpreter.llm.model = "deepinfra/codellama/CodeLlama-34b-Instruct-hf" interpreter.llm.model = "deepinfra/mistral-7b-instruct-v0.1" interpreter.llm.model = "deepinfra/jondurbin/airoboros-l2-70b-gpt4-1.4.1" ``` -------------------------------- ### Run Open Interpreter Server Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/jan_computer_control.ipynb Start the Open Interpreter server to make it compatible with OpenAI clients. You can add flags to configure settings like model and context window. ```bash interpreter --server ``` -------------------------------- ### Set Supported Cohere Models in Python Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/cohere.mdx Examples of setting various Cohere models programmatically in Python. ```python interpreter.llm.model = "command" interpreter.llm.model = "command-light" interpreter.llm.model = "command-medium" interpreter.llm.model = "command-medium-beta" interpreter.llm.model = "command-xlarge-beta" interpreter.llm.model = "command-nightly" ``` -------------------------------- ### Run Local Model Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Use the `--local` argument to run models directly on your machine. Consult the models page for setup details. ```bash interpreter --local ``` ```yaml local: true ``` -------------------------------- ### Inter-Instance Communication Example Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/guides/multiple-instances.mdx Demonstrates how to make multiple OpenInterpreter instances communicate by swapping roles and passing messages between them in a loop. Requires a helper function to swap message roles. ```python def swap_roles(messages): for message in messages: if message['role'] == 'user': message['role'] = 'assistant' elif message['role'] == 'assistant': message['role'] = 'user' return messages agents = [agent_1, agent_2] # Kick off the conversation messages = [{"role": "user", "message": "Hello!"}] while True: for agent in agents: messages = agent.chat(messages) messages = swap_roles(messages) ``` -------------------------------- ### Set Maximum Budget Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/python/budget-manager.mdx Set the maximum budget for the session in USD. This example sets the budget to 1 cent. ```python interpreter.max_budget = 0.01 # 1 cent ``` -------------------------------- ### Get Open Interpreter Version Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Display the current installed version number of Open Interpreter. ```bash interpreter --version ``` -------------------------------- ### Add Custom Instructions Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/settings/all-settings.mdx Appends custom instructions to the system message for guiding the model's behavior or providing context. ```bash interpreter --custom_instructions "This is a custom instruction." ``` ```python interpreter.custom_instructions = "This is a custom instruction." ``` ```yaml custom_instructions: "This is a custom instruction." ``` -------------------------------- ### Take a Screenshot Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Captures an image of the primary display. Use this to get visual context of the user's screen. ```python interpreter.computer.display.view() ``` -------------------------------- ### Run Open Interpreter from Terminal Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/getting-started/introduction.mdx Launch the Open Interpreter interface in your terminal. This command starts the interactive chat-like environment. ```bash interpreter ``` -------------------------------- ### Get Calendar Events Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Fetches calendar events within a specified date range from all configured calendars. Requires datetime objects for start and end dates. This function is only available on Mac. ```python interpreter.computer.calendar.get_events(start_date=datetime, end_date=datetime) ``` -------------------------------- ### Run Open Interpreter with Llamafile in Terminal Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md Easily run Open Interpreter locally using Llamafile without additional installations by using the `--local` flag. ```shell interpreter --local ``` -------------------------------- ### Configure System Message for Package Scanning Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/SAFE_MODE.md Adjust the `system_message` in your config file to instruct the model to scan packages with `guarddog` before installation. This example shows scanning pip and npm packages. ```yaml model: gpt-4 verbose: false safe_mode: ask system_message: | # normal system message here 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. ``` -------------------------------- ### Start Interactive Chat Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/guides/basic-usage.mdx Initiate an interactive chat session in your terminal or a Python script. This is the most straightforward way to begin using Open Interpreter. ```shell interpreter ``` ```python interpreter.chat() ``` -------------------------------- ### Add Custom Instructions Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Append custom instructions to the system message using `--custom_instructions`. This is useful for providing context about your system or preferences. An example instruction is included. ```bash interpreter --custom_instructions "This is a custom instruction." ``` ```yaml custom_instructions: "This is a custom instruction." ``` -------------------------------- ### Set Context Window Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Manually set the context window size in tokens using the `--context_window` argument. 16000 tokens is used as an example. ```bash interpreter --context_window 16000 ``` ```yaml context_window: 16000 ``` -------------------------------- ### Run Open Interpreter with Default OpenAI Model Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/openai.mdx Execute Open Interpreter using the default model, which is typically gpt-4-turbo. This is the simplest way to start using the tool. ```bash interpreter ``` ```python from interpreter import interpreter interpreter.chat() ``` -------------------------------- ### Create and Populate .docx Files Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/Open_Interpreter_Demo.ipynb Instructs Open Interpreter to create a folder named 'documents' and generate five .docx files within it. Each file contains a sentence about machine learning. ```python interpreter.messages = [] # Reset the chat interpreter.chat("Can you make a folder called documents and put five .docx files in it and write a sentence about machine learning in each of them?") # Pass a message directly into chat ``` -------------------------------- ### Set API Version Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Optionally specify the API version using the `--api_version` argument. This overrides environment variables. An example version is shown. ```bash interpreter --api_version 2.0.2 ``` ```yaml api_version: 2.0.2 ``` -------------------------------- ### OS - Get Selected Text Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Get the selected text on the screen. ```APIDOC ## OS - Get Selected Text ### Description Get the selected text on the screen. ### Method ```python interpreter.computer.os.get_selected_text() ``` ``` -------------------------------- ### Display Help Information Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Show all available terminal arguments and their descriptions. ```bash interpreter --help ``` -------------------------------- ### Configure Open Interpreter Instance Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/custom_tool.ipynb Set up your Open Interpreter instance by configuring LLM model, enabling computer API, and specifying model capabilities and context window. ```python from interpreter import interpreter interpreter.llm.model = "claude-3-5-sonnet-20240620" interpreter.computer.import_computer_api = True interpreter.llm.supports_functions = True interpreter.llm.supports_vision = True interpreter.llm.context_window = 100000 interpreter.llm.max_tokens = 4096 ``` -------------------------------- ### Configure and run the Open Interpreter server Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/local_server.ipynb Sets up a Flask application, configures Open Interpreter (with options for local or hosted models), defines a /chat endpoint to process prompts, and starts the server. Ensure to set your desired model and configuration. ```python app = Flask(__name__) # Configure Open Interpreter ## Local Model # interpreter.offline = True # interpreter.llm.model = "ollama/llama3.1" # interpreter.llm.api_base = "http://localhost:11434" # interpreter.llm.context_window = 4000 # interpreter.llm.max_tokens = 3000 # interpreter.auto_run = True # interpreter.verbose = True ## Hosted Model interpreter.llm.model = "gpt-4o" interpreter.llm.context_window = 10000 interpreter.llm.max_tokens = 4096 interpreter.auto_run = True # Create an endpoint @app.route('/chat', methods=['POST']) def chat(): # Expected payload: {"prompt": "User's message or question"} data = request.json prompt = data.get('prompt') if not prompt: return jsonify({"error": "No prompt provided"}), 400 full_response = "" try: for chunk in interpreter.chat(prompt, stream=True, display=False): if isinstance(chunk, dict): if chunk.get("type") == "message": full_response += chunk.get("content", "") elif isinstance(chunk, str): # Attempt to parse the string as JSON try: json_chunk = json.loads(chunk) full_response += json_chunk.get("response", "") except json.JSONDecodeError: # If it's not valid JSON, just add the string full_response += chunk except Exception as e: return jsonify({"error": str(e)}), 500 return jsonify({"response": full_response.strip()}) if __name__ == '__main__': app.run(host='0.0.0.0', port=5001) print("Open Interpreter server is running on http://0.0.0.0:5001") ``` -------------------------------- ### List Supported Perplexity Models Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/perplexity.mdx Examples of setting Open Interpreter to use specific supported models from the Perplexity API via the command line or Python. This includes chat and online models, as well as various instruct and chat variants. ```bash interpreter --model perplexity/pplx-7b-chat interpreter --model perplexity/pplx-70b-chat interpreter --model perplexity/pplx-7b-online interpreter --model perplexity/pplx-70b-online interpreter --model perplexity/codellama-34b-instruct interpreter --model perplexity/llama-2-13b-chat interpreter --model perplexity/llama-2-70b-chat interpreter --model perplexity/mistral-7b-instruct interpreter --model perplexity/openhermes-2-mistral-7b interpreter --model perplexity/openhermes-2.5-mistral-7b interpreter --model perplexity/pplx-7b-chat-alpha interpreter --model perplexity/pplx-70b-chat-alpha ``` ```python interpreter.llm.model = "perplexity/pplx-7b-chat" interpreter.llm.model = "perplexity/pplx-70b-chat" interpreter.llm.model = "perplexity/pplx-7b-online" interpreter.llm.model = "perplexity/pplx-70b-online" interpreter.llm.model = "perplexity/codellama-34b-instruct" interpreter.llm.model = "perplexity/llama-2-13b-chat" interpreter.llm.model = "perplexity/llama-2-70b-chat" interpreter.llm.model = "perplexity/mistral-7b-instruct" interpreter.llm.model = "perplexity/openhermes-2-mistral-7b" interpreter.llm.model = "perplexity/openhermes-2.5-mistral-7b" interpreter.llm.model = "perplexity/pplx-7b-chat-alpha" interpreter.llm.model = "perplexity/pplx-70b-chat-alpha" ``` -------------------------------- ### Reset Conversation History Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/guides/basic-usage.mdx Start a new, clean chat session. In the terminal, simply running `interpreter` starts a new chat. In Python, you can reset the conversation history by clearing the `interpreter.messages` list. ```shell interpreter ``` ```python interpreter.messages = [] ``` -------------------------------- ### Retrieve Specific Server Setting via HTTP GET Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Fetch a specific server setting by sending a GET request to the /settings/{property} endpoint. The response will be a JSON object containing the requested property. ```python response = requests.get("http://localhost:8000/settings/custom_instructions") print(response.json()) # Output: {"custom_instructions": "You only write Python code."} ``` -------------------------------- ### Display - Center Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Gets the x, y value of the center of the screen. ```APIDOC ## Display - Center ### Description Gets the x, y value of the center of the screen. ### Method ```python x, y = interpreter.computer.display.center() ``` ``` -------------------------------- ### Contacts - Get Email Address Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Returns the email of a contact name. (Mac only) ```APIDOC ## Contacts - Get Email Address ### Description Returns the email of a contact name. (Mac only) ### Method ```python interpreter.computer.contacts.get_phone_number("John Doe") ``` ``` -------------------------------- ### Reset Conversation Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/python/magic-commands.mdx Clears the entire conversation history, starting a new session. ```python %reset ``` -------------------------------- ### Configure Local Model via Python Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/local-models/best-practices.mdx Programmatically configure Open Interpreter for local models by setting `interpreter.llm.max_tokens` and `interpreter.llm.context_window`. Ensure `max_tokens` is less than `context_window`. This example also shows how to disable online features and point to a local OpenAI-compatible server. ```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.llm.max_tokens = 1000 interpreter.llm.context_window = 3000 interpreter.chat() ``` -------------------------------- ### Contacts - Get Phone Number Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Returns the phone number of a contact name. (Mac only) ```APIDOC ## Contacts - Get Phone Number ### Description Returns the phone number of a contact name. (Mac only) ### Method ```python interpreter.computer.contacts.get_phone_number("John Doe") ``` ``` -------------------------------- ### Calendar - Get Events Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Fetches calendar events for the given date or date range from all calendars. (Mac only) ```APIDOC ## Calendar - Get Events ### Description Fetches calendar events for the given date or date range from all calendars. (Mac only) ### Method ```python interpreter.computer.calendar.get_events(start_date=datetime, end_date=datetime) ``` ``` -------------------------------- ### Mail - Get Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Retrieves the last `number` emails from the inbox, optionally filtering for only unread emails. (Mac only) ```APIDOC ## Mail - Get ### Description Retrieves the last `number` emails from the inbox, optionally filtering for only unread emails. (Mac only) ### Method ```python interpreter.computer.mail.get(number=10, unread=True) ``` ``` -------------------------------- ### Initialize Open Interpreter with API Key Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/Open_Interpreter_Demo.ipynb Initializes the Open Interpreter and sets the OpenAI API key. Ensure you replace 'your_openai_api_key' with your actual key. ```python from interpreter import interpreter # Paste your OpenAI API key below. interpreter.llm.api_key = "your_openai_api_key" ``` -------------------------------- ### Python Integration with Sagemaker Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/aws-sagemaker.mdx Configure Open Interpreter to use a Sagemaker model programmatically. Requires `boto3` to be installed. ```python # Sagemaker requires boto3 to be installed on your machine: !pip install boto3 from interpreter import interpreter interpreter.llm.model = "sagemaker/" interpreter.chat() ``` -------------------------------- ### Configure Open Interpreter Settings Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/screenpipe.ipynb Sets up Open Interpreter with specific LLM model, disables computer API import, and configures LLM capabilities and context window. Also prints the current UTC date and time. ```python # Import necessary libraries from interpreter import interpreter from datetime import datetime, timezone # Configure Open Interpreter interpreter.llm.model = "groq/llama-3.1-70b-versatile" interpreter.computer.import_computer_api = False interpreter.llm.supports_functions = False interpreter.llm.supports_vision = False interpreter.llm.context_window = 100000 interpreter.llm.max_tokens = 4096 # Add the current date and time in UTC current_datetime = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC") print(f"Current date and time: {current_datetime}") ``` -------------------------------- ### Retrieve Server Settings Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Retrieves specific server settings by sending a GET request to the `/settings/{property}` endpoint. ```APIDOC ## Retrieve Server Settings Send a GET request to `http://localhost:8000/settings/{property}` to get current settings. ### Method GET ### Endpoint `/settings/{property}` ### Parameters #### Path Parameters - **property** (string) - Required - The name of the setting property to retrieve (e.g., `custom_instructions`). ### Request Example ```python response = requests.get("http://localhost:8000/settings/custom_instructions") print(response.json()) # Output: {"custom_instructions": "You only write Python code."} ``` ### Response #### Success Response (200) - **property_name** (any) - The value of the requested setting property. ``` -------------------------------- ### Apply Slow and Reverb Effects to Audio Source: https://github.com/openinterpreter/open-interpreter/blob/main/examples/Open_Interpreter_Demo.ipynb Demonstrates how to use Open Interpreter to apply audio effects, specifically slowing down a song and adding reverb. The command targets a YouTube link and processes the audio accordingly. ```python message = "Can you slow + reverb this song? https://www.youtube.com/watch?v=8GW6sLrK40k" interpreter.messages = [] interpreter.chat(message) ``` -------------------------------- ### Get Unread Mail Count Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Returns the total count of unread emails in the inbox. This function is only available on Mac. ```python interpreter.computer.mail.unread_count() ``` -------------------------------- ### Get Selected Text Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Retrieves the text that is currently highlighted or selected on the screen. This function requires OS-level access. ```python interpreter.computer.os.get_selected_text() ``` -------------------------------- ### Open Interpreter Configuration Commands Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md Commands to open the profiles directory and switch between different configurations using YAML files. ```bash interpreter --profiles ``` ```bash interpreter --profile my_profile.yaml ``` -------------------------------- ### Get Screen Center Coordinates Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Retrieves the X and Y coordinates for the center of the screen. Useful for positioning elements or clicks. ```python x, y = interpreter.computer.display.center() ``` -------------------------------- ### Show Help Message Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/python/magic-commands.mdx Displays the help message, listing all available magic commands and their usage. ```python %help ``` -------------------------------- ### Enable OS Mode with Custom Instructions Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/settings/example-profiles.mdx Configure Open Interpreter to run in OS mode, specifying custom instructions for browser and search tool preferences. ```yaml os: True custom_instructions: "Always use Safari as the browser, and use Raycast instead of spotlight search by pressing option + space." ``` -------------------------------- ### Get Contact Phone Number Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Retrieves the phone number associated with a given contact name. This function is only available on Mac. ```python interpreter.computer.contacts.get_phone_number("John Doe") ``` -------------------------------- ### Get Mail Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/code-execution/computer-api.mdx Retrieves a specified number of emails from the inbox, with an option to filter for unread messages. This function is only available on Mac. ```python interpreter.computer.mail.get(number=10, unread=True) ``` -------------------------------- ### Build Docker Image for Open Interpreter Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Build the Docker image for the Open Interpreter server from the repository root using the provided command. ```bash docker build -t open-interpreter . ``` -------------------------------- ### Set API Key Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Provide your API key for authentication with the `--api_key` argument. Replace the placeholder with your actual key. ```bash interpreter --api_key "your_api_key_here" ``` ```yaml api_key: your_api_key_here ``` -------------------------------- ### Run Open Interpreter with Local Server in Terminal Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md Connect to an OpenAI-compatible local inference server by specifying the `api_base` URL and a placeholder `api_key`. ```shell interpreter --api_base "http://localhost:1234/v1" --api_key "fake_key" ``` -------------------------------- ### Streaming Message Chunks Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/guides/streaming-response.mdx Shows how assistant messages are streamed. Each message is composed of multiple chunks, starting with `start=True` and ending with `end=True`. ```json {"role": "assistant", "type": "message", "start": True} ``` ```json {"role": "assistant", "type": "message", "content": "The"} ``` ```json {"role": "assistant", "type": "message", "content": " result"} ``` ```json {"role": "assistant", "type": "message", "content": " of"} ``` ```json {"role": "assistant", "type": "message", "content": " the"} ``` ```json {"role": "assistant", "type": "message", "content": " division"} ``` ```json {"role": "assistant", "type": "message", "content": " "} ``` ```json {"role": "assistant", "type": "message", "content": "34"} ``` ```json {"role": "assistant", "type": "message", "content": "/"} ``` ```json {"role": "assistant", "type": "message", "content": "24"} ``` ```json {"role": "assistant", "type": "message", "content": " is"} ``` ```json {"role": "assistant", "type": "message", "content": " approximately"} ``` ```json {"role": "assistant", "type": "message", "content": " "} ``` ```json {"role": "assistant", "type": "message", "content": "1"} ``` ```json {"role": "assistant", "type": "message", "content": "."} ``` ```json {"role": "assistant", "type": "message", "content": "42"} ``` ```json {"role": "assistant", "type": "message", "content": "."} ``` ```json {"role": "assistant", "type": "message", "end": True} ``` -------------------------------- ### Load a Profile with CLI Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/settings/profiles.mdx Use this command to load a specific profile by its name. Ensure the profile file is in the correct directory. ```bash interpreter --profile .yaml ``` -------------------------------- ### Enable Acknowledgement Feature (Bash) Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Set the INTERPRETER_REQUIRE_ACKNOWLEDGE environment variable to "True" before starting the interpreter server from the command line. ```bash export INTERPRETER_REQUIRE_ACKNOWLEDGE="True" interpreter --server ``` -------------------------------- ### Enable Multi-line Input Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/usage/terminal/arguments.mdx Allow multi-line inputs, which must start and end with triple backticks (```). This can be enabled via the terminal or configuration. ```bash interpreter --multi_line ``` ```yaml multi_line: true ``` -------------------------------- ### Enable LLM Function Support Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/settings/all-settings.mdx Inform Open Interpreter that the selected language model supports function calling. ```bash interpreter --llm_supports_functions ``` ```python interpreter.llm.supports_functions = True ``` ```yaml llm: supports_functions: true ``` -------------------------------- ### WebSocket API - Establishing Connection Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/server/usage.mdx Details on how to establish a connection to the Open Interpreter WebSocket server. ```APIDOC Connect to the WebSocket server at `ws://localhost:8000/`. ``` -------------------------------- ### Reset Conversation History in Python Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md To start a fresh conversation, clear the interpreter's message history by setting `interpreter.messages` to an empty list. ```python interpreter.messages = [] ``` -------------------------------- ### Use Open Interpreter in Python Source: https://github.com/openinterpreter/open-interpreter/blob/main/README.md Integrate Open Interpreter into your Python scripts. You can execute a single command or start an interactive chat session. ```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 ``` -------------------------------- ### Verify API Key on Windows Source: https://github.com/openinterpreter/open-interpreter/blob/main/docs/language-models/hosted-models/gpt-4-setup.mdx After setting the API key environment variable, use this command in a new command prompt to verify that it has been set correctly. ```cmd echo %OPENAI_API_KEY% ```