mamoodi 6b2ece35da
Release version 0.31.0 (#7629)
Co-authored-by: Robert Brennan <accounts@rbren.io>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
2025-04-02 15:30:45 -04:00

1.7 KiB

以下是翻译后的内容:

无头模式

你可以使用单个命令运行 OpenHands,而无需启动 Web 应用程序。 这使得使用 OpenHands 编写脚本和自动化任务变得很容易。

这与CLI 模式不同,后者是交互式的,更适合主动开发。

使用 Python

要在 Python 中以无头模式运行 OpenHands, 请按照开发设置说明, 然后运行:

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

你需要确保通过环境变量 config.toml 文件 设置你的模型、API 密钥和其他设置。

使用 Docker

  1. WORKSPACE_BASE 设置为你希望 OpenHands 编辑的目录:
WORKSPACE_BASE=$(pwd)/workspace
  1. LLM_MODEL 设置为你要使用的模型:
LLM_MODEL="anthropic/claude-3-5-sonnet-20241022"

  1. LLM_API_KEY 设置为你的 API 密钥:
LLM_API_KEY="sk_test_12345"
  1. 运行以下 Docker 命令:
docker run -it \
    --pull=always \
    -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.31-nikolaik \
    -e SANDBOX_USER_ID=$(id -u) \
    -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
    -e LLM_API_KEY=$LLM_API_KEY \
    -e LLM_MODEL=$LLM_MODEL \
    -e LOG_ALL_EVENTS=true \
    -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) \
    docker.all-hands.dev/all-hands-ai/openhands:0.31 \
    python -m openhands.core.main -t "write a bash script that prints hi" --no-auto-continue