Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update docs for headless mode #3508

Merged
merged 10 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ docker run -it \
```

> [!NOTE]
> By default, this command pulls the `latest` tag, which represents the most recent release of OpenHands. You have other options as well:
> This command pulls the `0.8` tag, which represents the most recent stable release of OpenHands. You have other options as well:
> - For a specific release version, use `ghcr.io/opendevin/opendevin:<OpenHands_version>` (replace <OpenHands_version> with the desired version number).
> - For the most up-to-date development version, use `ghcr.io/opendevin/opendevin:main`. This version may be **(unstable!)** and is recommended for testing or development purposes only.
>
Expand Down
41 changes: 41 additions & 0 deletions docs/modules/usage/how-to/headless-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Running in Headless Mode

You can run OpenHands via a CLI, without starting the web application. This makes it easy
to automate tasks with OpenHands.

## With Python
To run OpenHands in headless mode with Python,
[follow the Development setup instructions](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md),
and then run:

```bash
poetry run python -m openhands.core.main -t "write a bash script that prints hi"
```

## With Docker
To run OpenHands in headless mode with Docker, run:

```bash
# Set WORKSPACE_BASE to the directory you want OpenHands to edit
WORKSPACE_BASE=$(pwd)/workspace

# Set LLM_MODEL to the model you want to use
LLM_MODEL="gpt-4o"

# Set LLM_API_KEY to an API key, e.g. for OpenAI
LLM_API_KEY="abcde"

docker run -it \
--pull=always \
-e SANDBOX_USER_ID=$(id -u) \
-e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
-e LLM_API_KEY=$LLM_API_KEY \
-e LLM_MODEL=$LLM_MODEL \
-v $WORKSPACE_BASE:/opt/workspace_base \
-v /var/run/docker.sock:/var/run/docker.sock \
--add-host host.docker.internal:host-gateway \
--name openhands-app-$(date +%Y%m%d%H%M%S) \
ghcr.io/all-hands-ai/openhands:0.8 \
python -m opendevin.core.main \
-t "Write a bash script that prints Hello World"
```