### Configure Safe Mode with Guarddog Instructions Source: https://docs.openinterpreter.com/safety/safe-mode Example configuration file setting safe mode to 'ask' and including custom system instructions to scan packages with guarddog before installation. ```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. ``` -------------------------------- ### Download and Run LlamaFile Model Source: https://docs.openinterpreter.com/language-models/local-models/llamafile Download a LlamaFile model, make it executable, and start the local server. Ensure you have Xcode installed if using a Mac with Apple Silicon. ```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 ``` ```bash # In a separate terminal window, run OI and point it at the llamafile server interpreter --api_base https://localhost:8080/v1 ``` -------------------------------- ### Install Open Interpreter on Linux using curl Source: https://docs.openinterpreter.com/getting-started/setup Experimental installer for Linux. This command downloads and executes a script to install Open Interpreter, including Python and environment setup. ```bash curl -sL https://raw.githubusercontent.com/openinterpreter/open-interpreter/main/installers/oi-linux-installer.sh | bash ``` -------------------------------- ### Install Open Interpreter with Server dependencies Source: https://docs.openinterpreter.com/getting-started/setup Install optional dependencies required for running Open Interpreter as a server. ```bash pip install open-interpreter[server] ``` -------------------------------- ### Install Open Interpreter on Windows using PowerShell Source: https://docs.openinterpreter.com/getting-started/setup Experimental installer for Windows. This command uses PowerShell to download and run an installation script for Open Interpreter. ```powershell iex "& {$(irm https://raw.githubusercontent.com/openinterpreter/open-interpreter/main/installers/oi-windows-installer-conda.ps1)}" ``` -------------------------------- ### Install Open Interpreter on macOS using curl Source: https://docs.openinterpreter.com/getting-started/setup Experimental installer for macOS. This command downloads and executes a script to install Open Interpreter, including Python and environment setup. ```bash curl -sL https://raw.githubusercontent.com/openinterpreter/open-interpreter/main/installers/oi-mac-installer.sh | bash ``` -------------------------------- ### Install Petals Library Source: https://docs.openinterpreter.com/language-models/hosted-models/petals Install the Petals library using pip. This is a prerequisite for using Petals models with Open Interpreter. ```bash pip install git+https://github.com/bigscience-workshop/petals ``` -------------------------------- ### Get Version Source: https://docs.openinterpreter.com/settings Displays the currently installed version number of Open Interpreter. ```bash interpreter --version ``` -------------------------------- ### List of Supported DeepInfra Models (CLI) Source: https://docs.openinterpreter.com/language-models/hosted-models/deepinfra Examples of setting various supported DeepInfra models using the CLI. ```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 ``` -------------------------------- ### Install Open Interpreter with Local Mode dependencies Source: https://docs.openinterpreter.com/getting-started/setup Install optional dependencies for Open Interpreter's Local Mode, which allows running models locally. ```bash pip install open-interpreter[local] ``` -------------------------------- ### List Supported Petals Models Source: https://docs.openinterpreter.com/language-models/hosted-models/petals Examples of how to specify different Petals models via the command line or Python. Any model available on Petals can be used. ```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 Source: https://docs.openinterpreter.com/ Use this command to install the Open Interpreter package via pip. ```bash pip install open-interpreter ``` -------------------------------- ### Install Open Interpreter with Safe Mode dependencies Source: https://docs.openinterpreter.com/getting-started/setup Install optional dependencies for Open Interpreter's Safe Mode, which enhances security during execution. ```bash pip install open-interpreter[safe] ``` -------------------------------- ### Anyscale Supported Models via CLI Source: https://docs.openinterpreter.com/language-models/hosted-models/anyscale Examples of setting specific supported Anyscale models using the command line interface. ```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 ``` -------------------------------- ### Install Safety Toolkit Dependencies Separately Source: https://docs.openinterpreter.com/safety/safe-mode Install the safety toolkit dependencies, such as semgrep, individually in your virtual environment if you do not want to install the full bundle. ```shell pip install semgrep ``` -------------------------------- ### Use Supported Baseten Models via Command Line Source: https://docs.openinterpreter.com/language-models/hosted-models/baseten Examples of setting specific supported Baseten models (Falcon 7b, Wizard LM, MPT 7b Base) using the command line interface. ```bash interpreter --model baseten/qvv0xeq interpreter --model baseten/q841o8w interpreter --model baseten/31dxrj3 ``` -------------------------------- ### Use Supported Mistral Models via Command Line Source: https://docs.openinterpreter.com/language-models/hosted-models/mistral-api Examples of setting specific Mistral models (tiny, small, medium) using the command line. ```bash interpreter --model mistral/mistral-tiny interpreter --model mistral/mistral-small interpreter --model mistral/mistral-medium ``` -------------------------------- ### Configure Safe Mode in config.yaml Source: https://docs.openinterpreter.com/safety/safe-mode Example configuration file demonstrating how to set safe mode to 'ask'. This will prompt the user to confirm code scanning before execution. ```yaml model: gpt-4 temperature: 0 verbose: false safe_mode: ask ``` -------------------------------- ### Install Open Interpreter with OS Mode dependencies Source: https://docs.openinterpreter.com/getting-started/setup Install optional dependencies for Open Interpreter's OS Mode, enabling it to interact with your operating system. ```bash pip install open-interpreter[os] ``` -------------------------------- ### Install Open Interpreter via pip Source: https://docs.openinterpreter.com/getting-started/introduction Use this command to install the Open Interpreter Python package if you have Python already set up. ```bash pip install open-interpreter ``` -------------------------------- ### Use Supported Baseten Models via Python Source: https://docs.openinterpreter.com/language-models/hosted-models/baseten Examples of setting specific supported Baseten models (Falcon 7b, Wizard LM, MPT 7b Base) programmatically in Python. ```python interpreter.llm.model = "baseten/qvv0xeq" interpreter.llm.model = "baseten/q841o8w" interpreter.llm.model = "baseten/31dxrj3" ``` -------------------------------- ### List of Supported DeepInfra Models (Python) Source: https://docs.openinterpreter.com/language-models/hosted-models/deepinfra Examples of setting various supported DeepInfra models programmatically in Python. ```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/mistral-7b-instruct-v0.1" interpreter.llm.model = "deepinfra/jondurbin/airoboros-l2-70b-gpt4-1.4.1" ``` -------------------------------- ### Set Specific Perplexity Models via Command Line Source: https://docs.openinterpreter.com/language-models/hosted-models/perplexity Examples of setting various supported Perplexity models using the command line interface. ```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 ``` -------------------------------- ### Specify Various AWS SageMaker Llama 2 Models via CLI Source: https://docs.openinterpreter.com/language-models/hosted-models/aws-sagemaker Command-line examples for connecting to different pre-trained Llama 2 models and custom Huggingface deployments on AWS 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/ ``` -------------------------------- ### OS - Get Selected Text Source: https://docs.openinterpreter.com/code-execution/computer-api Get the selected text on the screen. ```APIDOC ## OS - Get Selected Text ### Description Get the selected text on the screen. ### Method `interpreter.computer.os.get_selected_text()` ``` -------------------------------- ### Run Open Interpreter Source: https://docs.openinterpreter.com/getting-started/introduction Execute this command in your terminal to start interacting with Open Interpreter through a ChatGPT-like interface. ```bash interpreter ``` -------------------------------- ### Mount Host Directory to Docker Container Source: https://docs.openinterpreter.com/integrations/docker Example of mounting a directory from the host machine into the Docker container to allow file access. ```bash docker run -d -it -v /path/on/your/host:/path/in/the/container --name interpreter-instance openinterpreter interpreter ``` -------------------------------- ### Use Supported Mistral Models via Python Source: https://docs.openinterpreter.com/language-models/hosted-models/mistral-api Examples of setting specific Mistral models (tiny, small, medium) programmatically in Python. ```python interpreter.llm.model = "mistral/mistral-tiny" interpreter.llm.model = "mistral/mistral-small" interpreter.llm.model = "mistral/mistral-medium" ``` -------------------------------- ### Dockerfile for Open Interpreter Source: https://docs.openinterpreter.com/integrations/docker This Dockerfile sets up a Python 3.11 environment, installs Open Interpreter, and configures the OpenAI 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 ``` -------------------------------- ### Run Open Interpreter with a Petals Model Source: https://docs.openinterpreter.com/language-models/hosted-models/petals Use this command to start Open Interpreter with a specific model from Petals. Ensure the model name is correctly specified. ```bash interpreter --model petals/petals-team/StableBeluga2 ``` -------------------------------- ### Inter-Instance Communication Example Source: https://docs.openinterpreter.com/guides/multiple-instances Demonstrates how two `OpenInterpreter` instances can converse by passing messages back and forth. The `swap_roles` function is a utility to alternate turns between agents. ```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) ``` -------------------------------- ### Run Open Interpreter with Jan.ai (Terminal) Source: https://docs.openinterpreter.com/language-models/local-models/janai Use this command in the terminal to start Open Interpreter with a model served by Jan.ai. Replace `` with the actual ID of your downloaded model. ```bash interpreter --api_base http://localhost:1337/v1 --model ``` -------------------------------- ### Run Open Interpreter Source: https://docs.openinterpreter.com/ Execute this command in your terminal to start an interactive chat session with Open Interpreter. ```bash interpreter ``` -------------------------------- ### Run Code with Pre-configured Environment Source: https://docs.openinterpreter.com/code-execution/usage Run code that sets up a specific environment, such as logging into a service like Replicate. This code is executed before the AI starts its chat session, ensuring the environment is ready. ```python interpreter.computer.run("python", "import replicate\nreplicate.api_key='...'" ) ``` -------------------------------- ### Set Specific Perplexity Models via Python Source: https://docs.openinterpreter.com/language-models/hosted-models/perplexity Examples of setting various supported Perplexity models programmatically in Python. ```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" ``` -------------------------------- ### Anyscale Supported Models via Python API Source: https://docs.openinterpreter.com/language-models/hosted-models/anyscale Examples of setting specific supported Anyscale models programmatically using the Python API. ```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" ``` -------------------------------- ### Streaming Console Output Format Source: https://docs.openinterpreter.com/guides/streaming-response This JSON example illustrates the format for receiving console output during code execution, including the active line being run. ```json {"role": "computer", "type": "console", "format": "active_line", "content": "1"} ``` ```json {"role": "computer", "type": "console", "format": "output", "content": "1.4166666666666667\n"} ``` ```json {"role": "computer", "type": "console", "end": True} ``` -------------------------------- ### Set vLLM API Base in Python Source: https://docs.openinterpreter.com/language-models/hosted-models/vllm Configure Open Interpreter to connect to your vLLM server by setting the api_base within your Python script. Ensure vLLM is installed. ```python from interpreter import interpreter interpreter.llm.api_base = "" interpreter.chat() ``` -------------------------------- ### Specify Various AWS SageMaker Llama 2 Models via Python SDK Source: https://docs.openinterpreter.com/language-models/hosted-models/aws-sagemaker Python code examples for setting different pre-trained Llama 2 models and custom Huggingface deployments on AWS SageMaker. ```python interpreter.llm.model = "sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b" interpreter.llm.model = "sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b-f" interpreter.llm.model = "sagemaker/jumpstart-dft-meta-textgeneration-llama-2-13b" interpreter.llm.model = "sagemaker/jumpstart-dft-meta-textgeneration-llama-2-13b-f" interpreter.llm.model = "sagemaker/jumpstart-dft-meta-textgeneration-llama-2-70b" interpreter.llm.model = "sagemaker/jumpstart-dft-meta-textgeneration-llama-2-70b-b-f" interpreter.llm.model = "sagemaker/" ``` -------------------------------- ### Use Specific Cloudflare Models in Terminal Source: https://docs.openinterpreter.com/language-models/hosted-models/cloudflare Examples of setting specific supported Cloudflare Workers AI models via the terminal. Choose the model that best suits your needs. ```bash interpreter --model cloudflare/@cf/meta/llama-2-7b-chat-fp16 ``` ```bash interpreter --model cloudflare/@cf/meta/llama-2-7b-chat-int8 ``` ```bash interpreter --model @cf/mistral/mistral-7b-instruct-v0.1 ``` ```bash interpreter --model @hf/thebloke/codellama-7b-instruct-awq ``` -------------------------------- ### Run Open Interpreter with Llamafile Locally Source: https://docs.openinterpreter.com/language-models/local-models/lm-studio This command enables local model execution using Llamafile without requiring third-party software installations. It's a simplified way to run models locally. ```shell interpreter --local ``` -------------------------------- ### Display Help Source: https://docs.openinterpreter.com/settings Shows all available command-line arguments for Open Interpreter. ```bash interpreter --help ``` -------------------------------- ### Set Vertex AI Model via Python Source: https://docs.openinterpreter.com/language-models/hosted-models/vertex-ai Configure the Vertex AI model programmatically within your Python script before starting a chat session. ```python from interpreter import interpreter interpreter.llm.model = "gemini-pro" interpreter.llm.model = "gemini-pro-vision" interpreter.chat() ``` -------------------------------- ### LMC Message Exchange Example Source: https://docs.openinterpreter.com/protocols/lmc-messages Demonstrates a typical interaction flow in the LMC architecture, including user messages, assistant code execution requests, computer console output, and assistant responses. ```json { "role": "user", "type": "message", "content": "What's 2380*3875?" } { "role": "assistant", "type": "code", "format": "python", "content": "2380*3875" } { "role": "computer", "type": "console", "format": "output", "content": "9222500" } { "role": "assistant", "type": "message", "content": "The result of multiplying 2380 by 3875 is 9222500." } ``` -------------------------------- ### List of Supported OpenRouter Models (CLI) Source: https://docs.openinterpreter.com/language-models/hosted-models/openrouter Demonstrates how to specify various OpenRouter models using the command line interface. ```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 ``` -------------------------------- ### Set Multiple Replicate Models via CLI Source: https://docs.openinterpreter.com/language-models/hosted-models/replicate Demonstrates setting different Replicate models using the command line interface. ```bash interpreter --model replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf interpreter --model replicate/a16z-infra/llama-2-13b-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52 interpreter --model replicate/vicuna-13b:6282abe6a492de4145d7bb601023762212f9ddbbe78278bd6771c8b3b2f2a13b interpreter --model replicate/daanelson/flan-t5-large:ce962b3f6792a57074a601d3979db5839697add2e4e02696b3ced4c022d4767f ``` -------------------------------- ### Streaming Message Chunks Source: https://docs.openinterpreter.com/guides/streaming-response Text messages are also streamed chunk-by-chunk. Each message starts with a 'start' chunk and ends with an 'end' chunk, with 'content' keys holding the text segments. ```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} ``` -------------------------------- ### Display - Center Source: https://docs.openinterpreter.com/code-execution/computer-api 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 `x, y = interpreter.computer.display.center()` ``` -------------------------------- ### Configure Local LLM with Max Tokens and Context Window Source: https://docs.openinterpreter.com/language-models/local-models/best-practices Use this command to set `max_tokens` and `context_window` for local LLM execution. Smaller context windows can reduce RAM usage. ```bash interpreter --local --max_tokens 1000 --context_window 3000 ``` -------------------------------- ### Contacts - Get Email Address Source: https://docs.openinterpreter.com/code-execution/computer-api 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 `interpreter.computer.contacts.get_email_address(name: str)` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the contact. ``` -------------------------------- ### Run Open Interpreter with Custom Instructions via Docker Compose Source: https://docs.openinterpreter.com/integrations/docker Demonstrates how to pass custom instructions to Open Interpreter when running it within a Docker container using docker-compose. ```bash docker-compose run --rm oi interpreter --custom_instructions "Be as concise as possible" ``` -------------------------------- ### Contacts - Get Phone Number Source: https://docs.openinterpreter.com/code-execution/computer-api 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 `interpreter.computer.contacts.get_phone_number(name: str)` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the contact. ``` -------------------------------- ### Perform Keyboard Hotkey Source: https://docs.openinterpreter.com/code-execution/computer-api Executes a hotkey combination on the computer. For example, to trigger a specific action. ```python interpreter.computer.keyboard.hotkey(" ", "command") ``` -------------------------------- ### Open Profile Configuration Source: https://docs.openinterpreter.com/guides/basic-usage Run this command to open the `default.yaml` profile file, where you can configure default settings like language model, system message, and budget. ```shell interpreter --profiles ``` -------------------------------- ### Calendar - Get Events Source: https://docs.openinterpreter.com/code-execution/computer-api 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 `interpreter.computer.calendar.get_events(start_date: datetime, end_date: datetime)` ### Parameters #### Path Parameters - **start_date** (datetime) - Required - The start date for fetching events. - **end_date** (datetime) - Required - The end date for fetching events. ``` -------------------------------- ### Mail - Get Source: https://docs.openinterpreter.com/code-execution/computer-api 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 `interpreter.computer.mail.get(number: int, unread: bool = False)` ### Parameters #### Path Parameters - **number** (integer) - Required - The number of emails to retrieve. - **unread** (boolean) - Optional - Filter for only unread emails. Defaults to False. ``` -------------------------------- ### List Supported Anthropic Models via CLI Source: https://docs.openinterpreter.com/language-models/hosted-models/anthropic Demonstrates setting different Anthropic models using the `--model` flag in the terminal. ```bash interpreter --model claude-instant-1 interpreter --model claude-instant-1.2 interpreter --model claude-2 ``` -------------------------------- ### Start Interactive Chat in Python Source: https://docs.openinterpreter.com/guides/basic-usage Call this function within a Python script to initiate an interactive chat. ```python interpreter.chat() ``` -------------------------------- ### List Supported AI21 Models in Terminal Source: https://docs.openinterpreter.com/language-models/hosted-models/ai21 Demonstrates how to set different AI21 models (j2-light, j2-mid, j2-ultra) via the terminal. ```bash interpreter --model j2-light interpreter --model j2-mid interpreter --model j2-ultra ``` -------------------------------- ### Get Screen Center Coordinates Source: https://docs.openinterpreter.com/code-execution/computer-api Retrieves the x, y coordinates of the center of the screen. Useful for positioning elements or actions. ```python x, y = interpreter.computer.display.center() ``` -------------------------------- ### Get Selected Text Source: https://docs.openinterpreter.com/code-execution/computer-api Retrieves the text that is currently selected on the screen. Requires visual selection by the user or another process. ```python interpreter.computer.os.get_selected_text() ``` -------------------------------- ### List of Supported OpenRouter Models (Python) Source: https://docs.openinterpreter.com/language-models/hosted-models/openrouter Shows how to set different OpenRouter models programmatically in Python. ```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" ``` -------------------------------- ### Set Azure Model via Python Source: https://docs.openinterpreter.com/language-models/hosted-models/azure Configure an Azure model programmatically within your Python script before starting a chat session. ```python from interpreter import interpreter interpreter.llm.model = "azure/" interpreter.chat() ``` -------------------------------- ### Contacts Operations: Get Phone Number and Email (Mac Only) Source: https://docs.openinterpreter.com/code-execution/computer-api Retrieves contact information such as phone numbers and email addresses by contact name. ```python interpreter.computer.contacts.get_phone_number("John Doe") ``` ```python interpreter.computer.contacts.get_email_address("John Doe") ``` -------------------------------- ### Enable LLM Function Support Source: https://docs.openinterpreter.com/settings Inform Open Interpreter that the selected language model supports function calling. ```bash interpreter --llm_supports_functions ``` -------------------------------- ### Set Anyscale Model via Python API Source: https://docs.openinterpreter.com/language-models/hosted-models/anyscale Configure the Anyscale model programmatically within your Python script before starting a chat session. ```python from interpreter import interpreter # Set the model to use from Anyscale: interpreter.llm.model = "anyscale/" interpreter.chat() ``` -------------------------------- ### Select Profile Source: https://docs.openinterpreter.com/settings Chooses a specific profile to use. If none is selected, the default profile is applied. ```bash interpreter --profile local.yaml ``` -------------------------------- ### List Supported Anthropic Models via Python Source: https://docs.openinterpreter.com/language-models/hosted-models/anthropic Shows how to set various Anthropic models by assigning to `interpreter.llm.model` in Python. ```python interpreter.llm.model = "claude-instant-1" interpreter.llm.model = "claude-instant-1.2" interpreter.llm.model = "claude-2" ``` -------------------------------- ### Restore Conversation with Messages Source: https://docs.openinterpreter.com/usage/python/arguments Demonstrates how to restore a previous conversation by assigning a list of messages to the interpreter. The messages list should resemble the structure shown in the example. ```python interpreter.messages = messages # A list that resembles the one above ``` -------------------------------- ### Enable LLM Vision Support Source: https://docs.openinterpreter.com/settings Inform Open Interpreter that the language model supports vision capabilities. Defaults to False. ```bash interpreter --llm_supports_vision ``` -------------------------------- ### Run Open Interpreter with Custom Config File via Docker Compose Source: https://docs.openinterpreter.com/integrations/docker Shows how to specify a custom configuration file for Open Interpreter when running it in a Docker container using docker-compose. ```bash docker-compose run --rm oi interpreter --config_file config.yml ``` -------------------------------- ### Reset Conversation History in Python Source: https://docs.openinterpreter.com/guides/basic-usage To start a fresh conversation in Python, clear the interpreter's message history by setting the `messages` attribute to an empty list. ```python interpreter.messages = [] ``` -------------------------------- ### Enable Verbose Mode for Computer (Profile) Source: https://docs.openinterpreter.com/settings/all-settings Enables verbose logging for debugging the virtual computer. ```Profile computer.verbose: True ``` -------------------------------- ### Set Context Window Source: https://docs.openinterpreter.com/settings Manually define the context window size in tokens. A smaller window uses less RAM, beneficial for local models on limited hardware. ```bash interpreter --context_window 16000 ``` -------------------------------- ### Set vLLM Model in Python Source: https://docs.openinterpreter.com/language-models/hosted-models/vllm Specify the vLLM model to be used by Open Interpreter within your Python script. Ensure vLLM is installed and the model identifier is correct. ```python from interpreter import interpreter interpreter.llm.model = "vllm/" interpreter.chat() ``` -------------------------------- ### Run Open Interpreter with LM Studio via Terminal Source: https://docs.openinterpreter.com/language-models/local-models/lm-studio Use this command to connect Open Interpreter to a locally running LM Studio server. Ensure LM Studio is running and serving models at the specified API base URL. ```shell interpreter --api_base "http://localhost:1234/v1" --api_key "fake_key" ``` -------------------------------- ### Run Open Interpreter with Jan.ai (Python) Source: https://docs.openinterpreter.com/language-models/local-models/janai Configure and run Open Interpreter programmatically using Python, connecting to the Jan.ai local API server. Ensure to replace `` with your model's ID. ```python from interpreter import interpreter interpreter.offline = True # Disables online features like Open Procedures interpreter.llm.model = "" interpreter.llm.api_base = "http://localhost:1337/v1 " interpreter.chat() ``` -------------------------------- ### Streaming Code Chunks Source: https://docs.openinterpreter.com/guides/streaming-response The LLM sends code token-by-token. Each chunk has a 'role' (assistant/computer), 'type' (code), 'format' (language), and either 'start', 'content', or 'end' keys. ```json {"role": "assistant", "type": "code", "format": "python", "start": True} ``` ```json {"role": "assistant", "type": "code", "format": "python", "content": "34"} ``` ```json {"role": "assistant", "type": "code", "format": "python", "content": " /"} ``` ```json {"role": "assistant", "type": "code", "format": "python", "content": " "} ``` ```json {"role": "assistant", "type": "code", "format": "python", "content": "24"} ``` ```json {"role": "assistant", "type": "code", "format": "python", "end": True} ``` -------------------------------- ### Configure Local LLM via Python Source: https://docs.openinterpreter.com/language-models/local-models/best-practices Configure Open Interpreter in Python for local LLM execution, setting `max_tokens` and `context_window`. Ensure `max_tokens` is less than `context_window`. ```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() ``` -------------------------------- ### Set Maximum Session Budget Source: https://docs.openinterpreter.com/usage/python/arguments Define the maximum budget limit for the entire session in USD using the `max_budget` property. This example sets the limit to 1 cent. ```python interpreter.max_budget = 0.01 # 1 cent ``` -------------------------------- ### Run Open Interpreter with OpenAI gpt-4o Model Source: https://docs.openinterpreter.com/language-models/hosted-models This command demonstrates how to run Open Interpreter with the gpt-4o model from OpenAI. Ensure your OPENAI_API_KEY is set. ```bash interpreter --model gpt-4o ``` -------------------------------- ### Modify System Message Source: https://docs.openinterpreter.com/usage/python/arguments Append instructions to the model's system message by modifying the `system_message` property. This example adds a directive to run shell commands with '-y'. ```python interpreter.system_message += "\nRun all shell commands with -y." ``` -------------------------------- ### Open Local Models Directory Source: https://docs.openinterpreter.com/settings Opens the directory where all downloaded Llamafiles are stored. ```bash interpreter --local_models ``` -------------------------------- ### Set AWS SageMaker Model via Python SDK Source: https://docs.openinterpreter.com/language-models/hosted-models/aws-sagemaker Configure Open Interpreter to use an AWS SageMaker endpoint within your Python code. Ensure boto3 is installed. ```python # Sagemaker requires boto3 to be installed on your machine: !pip install boto3 from interpreter import interpreter interpreter.llm.model = "sagemaker/" interpreter.chat() ``` -------------------------------- ### Set Together AI Model via CLI Source: https://docs.openinterpreter.com/language-models/hosted-models/togetherai Configure Open Interpreter to use a Together AI model directly from the command line. ```bash interpreter --model together_ai/ ``` -------------------------------- ### List Supported AI21 Models in Python Source: https://docs.openinterpreter.com/language-models/hosted-models/ai21 Shows how to set different AI21 models (j2-light, j2-mid, j2-ultra) programmatically in Python. ```python interpreter.llm.model = "j2-light" interpreter.llm.model = "j2-mid" interpreter.llm.model = "j2-ultra" ``` -------------------------------- ### Use Specific Cloudflare Models in Python Source: https://docs.openinterpreter.com/language-models/hosted-models/cloudflare Examples of setting specific supported Cloudflare Workers AI models within a Python script. Ensure you have the correct model identifier. ```python interpreter.llm.model = "cloudflare/@cf/meta/llama-2-7b-chat-fp16" ``` ```python interpreter.llm.model = "cloudflare/@cf/meta/llama-2-7b-chat-int8" ``` ```python interpreter.llm.model = "@cf/mistral/mistral-7b-instruct-v0.1" ``` ```python interpreter.llm.model = "@hf/thebloke/codellama-7b-instruct-awq" ``` -------------------------------- ### Calendar Operations: Get, Create, Delete Events (Mac Only) Source: https://docs.openinterpreter.com/code-execution/computer-api Manages calendar events, including fetching events for a date range, creating new events with details, and deleting specific events. ```python interpreter.computer.calendar.get_events(start_date=datetime, end_date=datetime) ``` ```python interpreter.computer.calendar.create_event(title="Title", start_date=datetime, end_date=datetime, location="Location", notes="Notes", calendar="Work") ``` ```python interpreter.computer.calendar.delete_event(event_title="Title", start_date=datetime, calendar="Work") ``` -------------------------------- ### Create Multiple OpenInterpreter Instances Source: https://docs.openinterpreter.com/guides/multiple-instances Instantiate multiple `OpenInterpreter` objects to manage separate agent contexts. Each instance can have a distinct `system_message`. ```python from interpreter import OpenInterpreter agent_1 = OpenInterpreter() agent_1.system_message = "This is a separate instance." agent_2 = OpenInterpreter() agent_2.system_message = "This is yet another instance." ``` -------------------------------- ### Console Output Chunks Source: https://docs.openinterpreter.com/guides/streaming-response Standard output from code execution is streamed. Chunks include 'type: console', with 'format' indicating 'active_line' or 'output'. Use 'start' and 'end' to delimit the output stream. ```json {"role": "computer", "type": "console", "start": True} ``` ```json {"role": "computer", "type": "console", "format": "active_line", "content": "1"} ``` ```json {"role": "computer", "type": "console", "format": "output", "content": "1.4166666666666667\n"} ``` ```json {"role": "computer", "type": "console", "format": "active_line", "content": null} ``` ```json {"role": "computer", "type": "console", "end": True} ``` -------------------------------- ### Run Open Interpreter with Ollama (Python) Source: https://docs.openinterpreter.com/language-models/local-models/ollama Configure and run Open Interpreter programmatically using Python, setting the model to an Ollama model and specifying the local API base. Disables online features. ```python from interpreter import interpreter interpreter.offline = True # Disables online features like Open Procedures interpreter.llm.model = "ollama_chat/" interpreter.llm.api_base = "http://localhost:11434" interpreter.chat() ``` -------------------------------- ### Enable OS Mode Source: https://docs.openinterpreter.com/guides/os-mode Run the interpreter with the `--os` flag to enable OS Mode. Ensure screen recording permissions are granted to your terminal application. ```bash interpreter --os ``` -------------------------------- ### Customize System Message in Python Source: https://docs.openinterpreter.com/guides/basic-usage Extend Open Interpreter's functionality or context by appending to the `system_message` attribute in Python. This example adds a directive to run shell commands without confirmation. ```python interpreter.system_message += "\nRun shell commands with -y so the user doesn't have to confirm them." print(interpreter.system_message) ``` -------------------------------- ### Set Baseten Model via Command Line Source: https://docs.openinterpreter.com/language-models/hosted-models/baseten Use this command to set a Baseten model for Open Interpreter from your terminal. Replace `` with the specific model identifier. ```bash interpreter --model baseten/ ``` -------------------------------- ### Build and Run Open Interpreter Docker Container Source: https://docs.openinterpreter.com/integrations/docker Commands to build the Docker image and run Open Interpreter in a detached, interactive container. ```bash docker build -t openinterpreter . docker run -d -it --name interpreter-instance openinterpreter interpreter docker attach interpreter-instance ``` -------------------------------- ### Mail Operations: Get, Send, Unread Count (Mac Only) Source: https://docs.openinterpreter.com/code-execution/computer-api Manages emails via the default mail application. Supports fetching emails (optionally unread), sending new emails with attachments, and counting unread messages. ```python interpreter.computer.mail.get(number=10, unread=True) ``` ```python interpreter.computer.mail.send("john@email.com", "Subject", "Body", ["path/to/attachment.pdf", "path/to/attachment2.pdf"]) ``` ```python interpreter.computer.mail.unread_count() ``` -------------------------------- ### Set Context Window in Profile Source: https://docs.openinterpreter.com/settings/all-settings Define the context window size for the language model in the profile configuration file. ```yaml llm: context_window: 16000 ``` -------------------------------- ### Define Custom Python Language with E2B Source: https://docs.openinterpreter.com/code-execution/custom-languages Define a custom language class, `PythonE2B`, that uses E2B to run Python code. This class must include `name`, `run`, `stop`, and `terminate` methods. The `run` method yields output in LMC Format. This setup ensures Python code blocks are executed in a sandboxed cloud environment. ```python import e2b class PythonE2B: """ This class contains all requirements for being a custom language in Open Interpreter: - name (an attribute) - run (a method) - stop (a method) - terminate (a method) You can use this class to run any language you know how to run, or edit any of the official languages (which also conform to this class). Here, we'll use E2B to power the `run` method. """ # This is the name that will appear to the LLM. name = "python" # Optionally, you can append some information about this language to the system message: system_message = "# Follow this rule: Every Python code block MUST contain at least one print statement." # (E2B isn't a Jupyter Notebook, so we added ^ this so it would print things, # instead of putting variables at the end of code blocks, which is a Jupyter thing.) def run(self, code): """Generator that yields a dictionary in LMC Format.""" # Run the code on E2B stdout, stderr = e2b.run_code('Python3', code) # Yield the output yield { "type": "console", "format": "output", "content": stdout + stderr # We combined these arbitrarily. Yield anything you'd like! } def stop(self): """Stops the code.""" # Not needed here, because e2b.run_code isn't stateful. pass def terminate(self): """Terminates the entire process.""" # Not needed here, because e2b.run_code isn't stateful. pass # (Tip: Do this before adding/removing languages, otherwise OI might retain the state of previous languages:) interpreter.computer.terminate() # Give Open Interpreter its languages. This will only let it run PythonE2B: interpreter.computer.languages = [PythonE2B] # Try it out! interpreter.chat("What's 349808*38490739?") ``` -------------------------------- ### Set NLP Cloud Model via CLI Source: https://docs.openinterpreter.com/language-models/hosted-models/nlp-cloud Use the `--model` flag in the terminal to specify an NLP Cloud model like 'dolphin'. ```bash interpreter --model dolphin ``` -------------------------------- ### Set API Version Source: https://docs.openinterpreter.com/settings Optionally specify the API version to use, overriding environment variables. ```bash interpreter --api_version 2.0.2 ``` -------------------------------- ### Run Open Interpreter with GPT-4o Model Source: https://docs.openinterpreter.com/language-models/hosted-models/openai Configure Open Interpreter to use the gpt-4o model. This demonstrates setting a specific model for advanced use cases. ```bash interpreter --model gpt-4o ``` ```python interpreter.llm.model = "gpt-4o" ``` -------------------------------- ### Enable Vision Mode Source: https://docs.openinterpreter.com/settings Activates vision mode, which modifies the prompt and defaults to using `gpt-4o` for enhanced visual understanding. ```bash interpreter --vision ``` -------------------------------- ### Run Open Interpreter with a Local Ollama Model Source: https://docs.openinterpreter.com/language-models/local-models Execute Open Interpreter using a locally downloaded Ollama model. This command can be run interactively or directly. ```bash interpreter --model ollama/ ``` -------------------------------- ### Run Open Interpreter with Default OpenAI Model Source: https://docs.openinterpreter.com/language-models/hosted-models/openai Run Open Interpreter using the default model, which is typically gpt-4-turbo. This is the recommended setting for optimal code interpretation. ```bash interpreter ``` ```python from interpreter import interpreter interpreter.chat() ``` -------------------------------- ### Configure and Test E2B Integration Source: https://docs.openinterpreter.com/integrations/e2b Terminate the current interpreter, assign the custom PythonE2B language, and test it with a chat query. ```python # (Tip: Do this before adding/removing languages, otherwise OI might retain the state of previous languages:) interpreter.computer.terminate() # Give Open Interpreter its languages. This will only let it run PythonE2B: interpreter.computer.languages = [PythonE2B] # Try it out! interpreter.chat("What's 349808*38490739?") ``` -------------------------------- ### Import Computer API Source: https://docs.openinterpreter.com/settings Set `import_computer_api` to True to automatically include the computer API in the system message. The default is False. ```python interpreter.computer.import_computer_api = True ``` -------------------------------- ### Enable Fast Mode Source: https://docs.openinterpreter.com/settings Sets the model to gpt-3.5-turbo and encourages it to only write code without confirmation. Ideal for rapid code generation tasks. ```bash interpreter --fast ``` -------------------------------- ### Enable LLM Function Support in Profile Source: https://docs.openinterpreter.com/settings/all-settings Configure the language model's function calling capability in the profile file. ```yaml llm: supports_functions: true ``` -------------------------------- ### Configure Custom Model Settings Source: https://docs.openinterpreter.com/language-models/custom-models Set the context window size, maximum tokens, and capabilities (vision and function support) for your custom language model. ```python interpreter.llm.context_window = 2000 # In tokens interpreter.llm.max_tokens = 1000 # In tokens interpreter.llm.supports_vision = False # Does this completions endpoint accept images? interpreter.llm.supports_functions = False # Does this completions endpoint accept/return function calls? ``` -------------------------------- ### Download an Ollama Model Source: https://docs.openinterpreter.com/language-models/local-models Use this command to download a specific language model through Ollama. Ensure you replace '' with your desired model. ```bash ollama run ``` -------------------------------- ### Set vLLM API Base Source: https://docs.openinterpreter.com/language-models/hosted-models/vllm Configure Open Interpreter to connect to your vLLM server by setting the api_base. This is typically done via the command line or within Python code. ```bash interpreter --api_base ``` -------------------------------- ### Set Custom Context Window (Python) Source: https://docs.openinterpreter.com/language-models/local-models/janai Programmatically set a custom context window size for Open Interpreter when using a Jan.ai model with extended context capabilities. ```python from interpreter import interpreter interpreter.context_window = 5000 ``` -------------------------------- ### Display - View Source: https://docs.openinterpreter.com/code-execution/computer-api Takes a screenshot of the primary display. ```APIDOC ## Display - View ### Description Takes a screenshot of the primary display. ### Method `interpreter.computer.display.view()` ``` -------------------------------- ### Set Huggingface API Base URL via CLI Source: https://docs.openinterpreter.com/language-models/hosted-models/huggingface Specify a custom Huggingface API base URL using the command line. ```bash interpreter --api_base ``` -------------------------------- ### Interactive Code Execution with Streaming Source: https://docs.openinterpreter.com/guides/streaming-response This Python snippet shows how to stream responses from the interpreter and prompt the user before executing code. It handles 'executing' chunks to allow user confirmation. ```python for chunk in interpreter.chat("What's 34/24?", stream=True): if "executing" in chunk: if input("Press ENTER to run this code.") != "": break ```