Robert Brennan ee158feb15
Documentation updates (#3733)
* update badges

* fix badges

* better badges

* move credits

* more badge work

* add gh logo

* update some copy

* update logo

* fix height

* update text

* emdash

* remove cruft

* move title

* update links

* add hr

* white logo

* move some stuff to getting-started

* revert logo

* more copy changes

* minor tweaks

* fix sidebar

* explicit sidebar

* words

* fix tag

* fix how-to

* more docs work

* update styles

* fix up custom sandbox docs

* change eval title

* fix up getting-started

* fix getting started

* update to 0.9.2

* update screenshot

* add company link

* fix dark mode

* minor fixes

* update image

* update headless and cli docs

* update readme

* fix links

* revert package

* rename links

* fix links

* fix link

* chagne to claude
2024-09-04 21:22:52 +00:00

2.6 KiB
Raw Blame History

CLI Mode

OpenHands can be run in an interactive CLI mode, which allows users to start an interactive session via the command line.

This mode is different from the headless mode, which is non-interactive and better for scripting.

With Python

To start an interactive OpenHands session via the command line, follow these steps:

  1. Ensure you have followed the Development setup instructions.

  2. Run the following command:

poetry run python -m openhands.core.cli

This command will start an interactive session where you can input tasks and receive responses from OpenHands.

You'll need to be sure to set your model, API key, and other settings via environment variables or the config.toml file.

With Docker

To run OpenHands in CLI mode with Docker, follow these steps:

  1. Set WORKSPACE_BASE to the directory you want OpenHands to edit:
WORKSPACE_BASE=$(pwd)/workspace
  1. Set LLM_MODEL to the model you want to use:
LLM_MODEL="claude-3-5-sonnet-20240620"
  1. Set LLM_API_KEY to an API key, e.g., for OpenAI or Anthropic:
LLM_API_KEY="abcde"
  1. Run the following Docker command:
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.9 \
    poetry run python -m openhands.core.cli

This command will start an interactive session in Docker where you can input tasks and receive responses from OpenHands.

Examples of CLI Commands and Expected Outputs

Here are some examples of CLI commands and their expected outputs:

Example 1: Simple Task

How can I help? >> Write a Python script that prints "Hello, World!"

Expected Output:

🤖 Sure! Here is a Python script that prints "Hello, World!":

 print("Hello, World!")

Example 2: Bash Command

How can I help? >> Create a directory named "test_dir"

Expected Output:

🤖 Creating a directory named "test_dir":

 mkdir test_dir

Example 3: Error Handling

How can I help? >> Delete a non-existent file

Expected Output:

🤖 An error occurred. Please try again.