# Open WebUI

用于在 CLORE.AI GPU 上运行大型语言模型的类似 ChatGPT 的精美界面。

{% hint style="success" %}
所有示例都可以在通过以下方式租用的 GPU 服务器上运行： [CLORE.AI 市场](https://clore.ai/marketplace).
{% endhint %}

## 为什么选择 Open WebUI？

* **类似 ChatGPT 的界面** - 熟悉且精致的界面
* **多模型** - 轻松在模型之间切换
* **内置 RAG** - 上传文档以提供上下文
* **用户管理** - 支持多用户
* **历史记录** - 会话持久化
* **Ollama 集成** - 开箱即用

## 在 CLORE.AI 上快速部署

**Docker 镜像：**

```
ghcr.io/open-webui/open-webui:cuda
```

**端口：**

```
22/tcp
8080/http
```

**命令：**

```bash
# 在后台启动 Ollama
ollama serve &
sleep 5
ollama pull llama3.2

# 启动 Open WebUI（会自动连接到 Ollama）
# 注意：Docker 镜像已处理此项
```

## 访问您的服务

部署后，在以下位置查找您的 `http_pub` URL： **我的订单**:

1. 前往 **我的订单** 页面
2. 单击您的订单
3. 查找 `http_pub` URL（例如， `abc123.clorecloud.net`)

使用 `https://YOUR_HTTP_PUB_URL` 而不是 `localhost` 在下面的示例中。

### 验证是否正常运行

```bash
# 检查健康状态
curl https://your-http-pub.clorecloud.net/health

# 获取版本
curl https://your-http-pub.clorecloud.net/api/version
```

响应：

```json
{"version": "0.7.2"}
```

{% hint style="warning" %}
如果收到 HTTP 502，请等待 1-2 分钟——服务仍在启动中。
{% endhint %}

## 安装

### 使用 Ollama（推荐）

```bash
# 先启动 Ollama
docker run -d --gpus all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

# 拉取模型
docker exec -it ollama ollama pull llama3.2

# 启动 Open WebUI
docker run -d -p 8080:8080 \
  --add-host=host.docker.internal:host-gateway \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main
```

### 一体化（捆绑 Ollama）

```bash
docker run -d -p 8080:8080 \
  --gpus all \
  -v ollama:/root/.ollama \
  -v open-webui:/app/backend/data \
  --name open-webui \
  ghcr.io/open-webui/open-webui:ollama
```

## 首次设置

1. 打开 `http://your-server:8080`
2. 创建管理员账户（第一个用户将成为管理员）
3. 前往 设置 → 模型 → 拉取模型
4. 开始聊天！

## 功能

### 聊天界面

* Markdown 渲染
* 代码高亮
* 图像生成（与兼容模型）
* 语音输入/输出
* 文件附件

### 模型管理

* 可直接从 UI 拉取模型
* 创建自定义模型
* 设置默认模型
* 模型专属设置

### RAG（文档聊天）

1. 在聊天中点击 "+"
2. 上传 PDF、TXT 或其他文档
3. 就内容提问

### 用户管理

* 多用户
* 基于角色的访问控制
* API 密钥管理
* 使用情况跟踪

## 配置

### 使用环境变量进行 SSH 和 Jupyter 访问：

```bash
docker run -d \
  -e OLLAMA_BASE_URL=http://ollama:11434 \
  -e WEBUI_AUTH=True \
  -e WEBUI_NAME="My AI Chat" \
  -e DEFAULT_MODELS="llama3.2" \
  ghcr.io/open-webui/open-webui:main
```

### 关键设置

| 变量                      | 4s             | 默认值                      |
| ----------------------- | -------------- | ------------------------ |
| `OLLAMA_BASE_URL`       | Ollama API URL | `http://localhost:11434` |
| `WEBUI_AUTH`            | 启用认证           | `True`                   |
| `WEBUI_NAME`            | 实例名称           | `打开 WebUI`               |
| `DEFAULT_MODELS`        | 默认模型           | -                        |
| `ENABLE_RAG_WEB_SEARCH` | RAG 中的网页搜索     | `False`                  |

### 连接到远程 Ollama

```bash
docker run -d -p 8080:8080 \
  -e OLLAMA_BASE_URL=http://remote-server:11434 \
  ghcr.io/open-webui/open-webui:main
```

## Docker Compose

```yaml
version: '3.8'

services:
  ollama:
    image: ollama/ollama
    container_name: ollama
    volumes:
      - ollama:/root/.ollama
    ports:
      - "11434:11434"
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    volumes:
      - open-webui:/app/backend/data
    ports:
      - "8080:8080"
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
    depends_on:
      - ollama

volumes:
  ollama:
  open-webui:
```

```bash
docker-compose up -d
```

## API 参考

Open WebUI 提供多个 API 端点：

| 端点                 | 方法   | 4s               |
| ------------------ | ---- | ---------------- |
| `/health`          | GET  | 健康检查             |
| `/api/version`     | GET  | 获取 Open WebUI 版本 |
| `/api/config`      | GET  | 获取配置             |
| `/ollama/api/tags` | GET  | 列出 Ollama 模型（代理） |
| `/ollama/api/chat` | POST | 与 Ollama 聊天（代理）  |

### 检查健康状态

```bash
curl https://your-http-pub.clorecloud.net/health
```

响应： `true`

### 获取版本

```bash
curl https://your-http-pub.clorecloud.net/api/version
```

响应：

```json
{"version": "0.7.2"}
```

### 列出模型（通过 Ollama 代理）

```bash
curl https://your-http-pub.clorecloud.net/ollama/api/tags
```

{% hint style="info" %}
大多数 API 操作需要认证。使用网页 UI 创建账户并管理 API 密钥。
{% endhint %}

## 提示

### 更快的响应

1. 使用量化模型（Q4\_K\_M）
2. 在设置中启用流式传输
3. 如有需要，减少上下文长度

### 更好的质量

1. 使用更大的模型（13B 及以上）
2. 使用 Q8 量化
3. 在模型设置中调整温度

### 节省资源

1. 设置 `OLLAMA_KEEP_ALIVE=5m`
2. 卸载未使用的模型
3. 测试时使用更小的模型

## GPU 要求

相同于 [Ollama](https://docs.clore.ai/guides/guides_v2-zh/ollama#gpu-requirements).

Open WebUI 本身使用的资源很少（约 500MB 内存）。

## # 使用固定种子以获得一致结果

### 无法连接到 Ollama

```bash
# 检查 Ollama 是否正在运行
curl http://localhost:11434/api/tags

# 如果使用 Docker，请使用主机网络或正确的 URL
docker run --network=host ghcr.io/open-webui/open-webui:main
```

### 模型未显示

1. 在设置中检查 Ollama 连接
2. 刷新模型列表
3. 通过 CLI 拉取模型： `ollama pull modelname`

### 性能缓慢

1. 检查是否使用了 GPU： `nvidia-smi`
2. 尝试更小/量化的模型
3. 减少并发用户数

## 下载所有所需的检查点

| 设置      | GPU     | 每小时     |
| ------- | ------- | ------- |
| 基础（7B）  | 按小时费率   | \~$0.03 |
| 标准（13B） | 速度      | \~$0.06 |
| 高级（34B） | 512x512 | \~$0.10 |
| 企业（70B） | 2s      | \~$0.17 |

## 使用以下方式支付

* [Ollama](https://docs.clore.ai/guides/guides_v2-zh/yu-yan-mo-xing/ollama) - CLI 使用
* [LocalAI](https://docs.clore.ai/guides/guides_v2-zh/yu-yan-mo-xing/localai-openai-compatible) - 更多后端
* [RAG + LangChain](https://docs.clore.ai/guides/guides_v2-zh/xun-lian/finetune-llm) - 高级 RAG


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/yu-yan-mo-xing/open-webui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
