Skip to content

Latest commit

 

History

History
128 lines (96 loc) · 5.25 KB

Development.md

File metadata and controls

128 lines (96 loc) · 5.25 KB

Development Guide

This guide is for people working on OpenHands and editing the source code. If you wish to contribute your changes, check out the CONTRIBUTING.md on how to clone and setup the project initially before moving on. Otherwise, you can clone the OpenHands project directly.

Start the server for development

1. Requirements

  • Linux, Mac OS, or WSL on Windows [Ubuntu <= 22.04]
  • Docker (For those on MacOS, make sure to allow the default Docker socket to be used from advanced settings!)
  • Python = 3.12
  • NodeJS >= 18.17.1
  • Poetry >= 1.8
  • OS-specific dependencies:
    • Ubuntu: build-essential => sudo apt-get install build-essential
    • WSL: netcat => sudo apt-get install netcat

Make sure you have all these dependencies installed before moving on to make build.

Develop without sudo access

If you want to develop without system admin/sudo access to upgrade/install Python and/or NodeJs, you can use conda or mamba to manage the packages for you:

# Download and install Mamba (a faster version of conda)
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh

# Install Python 3.12, nodejs, and poetry
mamba install python=3.12
mamba install conda-forge::nodejs
mamba install conda-forge::poetry

2. Build and Setup The Environment

Begin by building the project which includes setting up the environment and installing dependencies. This step ensures that OpenHands is ready to run on your system:

make build

3. Configuring the Language Model

OpenHands supports a diverse array of Language Models (LMs) through the powerful litellm library. By default, we've chosen Claude Sonnet 3.5 as our go-to model, but the world is your oyster! You can unleash the potential of any other LM that piques your interest.

To configure the LM of your choice, run:

make setup-config

This command will prompt you to enter the LLM API key, model name, and other variables ensuring that OpenHands is tailored to your specific needs. Note that the model name will apply only when you run headless. If you use the UI, please set the model in the UI.

Note: If you have previously run OpenHands using the docker command, you may have already set some environmental variables in your terminal. The final configurations are set from highest to lowest priority: Environment variables > config.toml variables > default variables

Note on Alternative Models: See our documentation for recommended models.

4. Running the application

Option A: Run the Full Application

Once the setup is complete, launching OpenHands is as simple as running a single command. This command starts both the backend and frontend servers seamlessly, allowing you to interact with OpenHands:

make run

Option B: Individual Server Startup

  • Start the Backend Server: If you prefer, you can start the backend server independently to focus on backend-related tasks or configurations.

    make start-backend
  • Start the Frontend Server: Similarly, you can start the frontend server on its own to work on frontend-related components or interface enhancements.

    make start-frontend

6. LLM Debugging

If you encounter any issues with the Language Model (LM) or you're simply curious, you can inspect the actual LLM prompts and responses. To do so, export DEBUG=1 in the environment and restart the backend. OpenHands will then log the prompts and responses in the logs/llm/CURRENT_DATE directory, allowing you to identify the causes.

7. Help

Need assistance or information on available targets and commands? The help command provides all the necessary guidance to ensure a smooth experience with OpenHands.

make help

8. Testing

To run tests, refer to the following:

Unit tests

poetry run pytest ./tests/unit/test_*.py

9. Add or update dependency

  1. Add your dependency in pyproject.toml or use poetry add xxx
  2. Update the poetry.lock file via poetry lock --no-update

9. Use existing Docker image

To reduce build time (e.g., if no changes were made to the client-runtime component), you can use an existing Docker container image by setting the SANDBOX_RUNTIME_CONTAINER_IMAGE environment variable to the desired Docker image.

Example: export SANDBOX_RUNTIME_CONTAINER_IMAGE=ghcr.io/all-hands-ai/runtime:0.16-nikolaik

Develop inside Docker container

TL;DR

make docker-dev

See more details here

If you are just interested in running OpenHands without installing all the required tools on your host.

make docker-run

If you do not have make on your host, run:

cd ./containers/dev
./dev.sh

You do need Docker installed on your host though.