mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-08 22:38:05 -05:00
Simplify workspace mounting with SANDBOX_VOLUMES (#8242)
This commit is contained in:
@@ -2,13 +2,60 @@
|
||||
|
||||
## 系统要求
|
||||
|
||||
* Docker 版本 26.0.0+ 或 Docker Desktop 4.31.0+。
|
||||
* 你必须使用 Linux 或 Mac OS。
|
||||
* 如果你使用的是 Windows,你必须使用 [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)。
|
||||
- 支持 [Docker Desktop](https://docs.docker.com/desktop/setup/install/mac-install/#system-requirements) 的 MacOS
|
||||
- Linux
|
||||
- 配有 [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) 和 [Docker Desktop 支持](https://docs.docker.com/desktop/setup/install/windows-install/#system-requirements) 的 Windows
|
||||
|
||||
建议使用具有现代处理器和至少 **4GB RAM** 的系统来运行 OpenHands。
|
||||
|
||||
## 前提条件
|
||||
|
||||
<details>
|
||||
<summary>MacOS</summary>
|
||||
|
||||
**Docker Desktop**
|
||||
|
||||
1. [在 Mac 上安装 Docker Desktop](https://docs.docker.com/desktop/setup/install/mac-install)。
|
||||
2. 打开 Docker Desktop,进入 `Settings > Advanced` 并确保启用了 `Allow the default Docker socket to be used`。
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Linux</summary>
|
||||
|
||||
:::note
|
||||
已在 Ubuntu 22.04 上测试通过。
|
||||
:::
|
||||
|
||||
**Docker Desktop**
|
||||
|
||||
1. [在 Linux 上安装 Docker Desktop](https://docs.docker.com/desktop/setup/install/linux/)。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Windows</summary>
|
||||
|
||||
**WSL**
|
||||
|
||||
1. [安装 WSL](https://learn.microsoft.com/en-us/windows/wsl/install)。
|
||||
2. 在 powershell 中运行 `wsl --version` 并确认 `Default Version: 2`。
|
||||
|
||||
**Docker Desktop**
|
||||
|
||||
1. [在 Windows 上安装 Docker Desktop](https://docs.docker.com/desktop/setup/install/windows-install)。
|
||||
2. 打开 Docker Desktop,进入 `Settings` 并确认以下设置:
|
||||
- General: 启用 `Use the WSL 2 based engine`。
|
||||
- Resources > WSL Integration: 启用 `Enable integration with my default WSL distro`。
|
||||
|
||||
:::note
|
||||
下面启动应用的 docker 命令必须在 WSL 终端内运行。
|
||||
:::
|
||||
|
||||
</details>
|
||||
|
||||
## 启动应用
|
||||
|
||||
在 Docker 中运行 OpenHands 是最简单的方式。
|
||||
运行 OpenHands 最简单的方法是使用 Docker。
|
||||
|
||||
```bash
|
||||
docker pull docker.all-hands.dev/all-hands-ai/runtime:0.36-nikolaik
|
||||
@@ -17,38 +64,56 @@ docker run -it --rm --pull=always \
|
||||
-e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.36-nikolaik \
|
||||
-e LOG_ALL_EVENTS=true \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v ~/.openhands-state:/.openhands-state \
|
||||
-p 3000:3000 \
|
||||
--add-host host.docker.internal:host-gateway \
|
||||
--name openhands-app \
|
||||
docker.all-hands.dev/all-hands-ai/openhands:0.36
|
||||
```
|
||||
|
||||
你也可以在可脚本化的[无头模式](https://docs.all-hands.dev/modules/usage/how-to/headless-mode)下运行 OpenHands,作为[交互式 CLI](https://docs.all-hands.dev/modules/usage/how-to/cli-mode),或使用 [OpenHands GitHub Action](https://docs.all-hands.dev/modules/usage/how-to/github-action)。
|
||||
OpenHands 将在 http://localhost:3000 运行!
|
||||
|
||||
你还可以[将 OpenHands 连接到本地文件系统](https://docs.all-hands.dev/modules/usage/runtimes/docker#connecting-to-your-filesystem),
|
||||
以[无头模式](https://docs.all-hands.dev/modules/usage/how-to/headless-mode)运行 OpenHands,
|
||||
通过[友好的 CLI](https://docs.all-hands.dev/modules/usage/how-to/cli-mode)与其交互,
|
||||
或者使用 [GitHub action](https://docs.all-hands.dev/modules/usage/how-to/github-action) 在标记的问题上运行它。
|
||||
|
||||
## 设置
|
||||
|
||||
运行上述命令后,你可以在 [http://localhost:3000](http://localhost:3000) 找到正在运行的 OpenHands。
|
||||
启动 OpenHands 后,你**必须**选择一个 `LLM Provider` 和 `LLM Model` 并输入相应的 `API Key`。
|
||||
这可以在初始设置弹窗中完成,或者通过在 UI 中选择 `Settings` 按钮(齿轮图标)来完成。
|
||||
|
||||
启动 OpenHands 后,你会看到一个设置模态框。你**必须**选择一个 `LLM Provider` 和 `LLM Model`,并输入相应的 `API Key`。
|
||||
这些设置可以随时通过选择 UI 中的 `Settings` 按钮(齿轮图标)进行更改。
|
||||
如果列表中不存在所需的模型,你可以切换 `Advanced` 选项,并在 `Custom Model` 文本框中手动输入带有正确前缀的模型。
|
||||
`Advanced` 选项还允许你在需要时指定 `Base URL`。
|
||||
|
||||
如果所需的 `LLM Model` 不在列表中,你可以切换 `Advanced Options`,并在 `Custom Model` 文本框中使用正确的前缀手动输入。
|
||||
`Advanced Options` 还允许你在需要时指定 `Base URL`。
|
||||
### 获取 API 密钥
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'center', gap: '20px' }}>
|
||||
<img src="/img/settings-screenshot.png" alt="settings-modal" width="340" />
|
||||
<img src="/img/settings-advanced.png" alt="settings-modal" width="335" />
|
||||
</div>
|
||||
OpenHands 需要 API 密钥才能访问大多数语言模型。以下是从推荐提供商获取 API 密钥的方法:
|
||||
|
||||
#### Anthropic (Claude)
|
||||
|
||||
1. [创建 Anthropic 账户](https://console.anthropic.com/)。
|
||||
2. [生成 API 密钥](https://console.anthropic.com/settings/keys)。
|
||||
3. [设置计费](https://console.anthropic.com/settings/billing)。
|
||||
|
||||
考虑设置使用限制以控制成本。
|
||||
|
||||
#### OpenAI
|
||||
|
||||
1. [创建 OpenAI 账户](https://platform.openai.com/)。
|
||||
2. [生成 API 密钥](https://platform.openai.com/api-keys)。
|
||||
3. [设置计费](https://platform.openai.com/account/billing/overview)。
|
||||
|
||||
现在你已准备好[开始使用 OpenHands](./getting-started)。
|
||||
|
||||
## 版本
|
||||
|
||||
上述命令拉取最新的 OpenHands 稳定版本。你还有其他选择:
|
||||
- 对于特定版本,使用 `docker.all-hands.dev/all-hands-ai/openhands:$VERSION`,将 $VERSION 替换为版本号。
|
||||
- 我们使用语义化版本,并发布主要版本、次要版本和补丁标签。因此,`0.9` 将自动指向最新的 `0.9.x` 版本,而 `0` 将指向最新的 `0.x.x` 版本。
|
||||
- 对于最新的开发版本,你可以使用 `docker.all-hands.dev/all-hands-ai/openhands:main`。此版本不稳定,仅建议用于测试或开发目的。
|
||||
|
||||
你可以根据稳定性要求和所需功能选择最适合你需求的标签。
|
||||
[上面的 docker 命令](./installation#start-the-app)会拉取 OpenHands 的最新稳定版本。你还有其他选择:
|
||||
- 对于特定版本,请在 `openhands:$VERSION` 和 `runtime:$VERSION` 中将 $VERSION 替换为版本号。
|
||||
我们使用 SemVer,因此 `0.9` 将自动指向最新的 `0.9.x` 版本,而 `0` 将指向最新的 `0.x.x` 版本。
|
||||
- 对于最新的开发版本,请在 `openhands:$VERSION` 和 `runtime:$VERSION` 中将 $VERSION 替换为 `main`。
|
||||
此版本不稳定,仅推荐用于测试或开发目的。
|
||||
|
||||
有关开发工作流程,请参阅 [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md)。
|
||||
|
||||
遇到问题了吗?查看我们的[故障排除指南](https://docs.all-hands.dev/modules/usage/troubleshooting)。
|
||||
遇到问题?请查看我们的[故障排除指南](https://docs.all-hands.dev/modules/usage/troubleshooting)。
|
||||
Reference in New Issue
Block a user