Skip to content

Commit 7d348dc

Browse files
committed
docs(readme): sync Chinese README with delegation mode docs
- Add VISION_MODE and VISION_SUBAGENT_NAME env vars to table - Add delegation modes section (api / subagent) with setup guide - Document auto-fallback behavior
1 parent 34dff9e commit 7d348dc

1 file changed

Lines changed: 69 additions & 9 deletions

File tree

README.md

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,80 @@ vision 工具:
7575

7676
## 环境变量
7777

78-
| 变量 | 说明 | 默认值 / 示例 |
79-
| ------------------ | -------------------------------------- | ------------------------------------------------------------- |
80-
| `VISION_API_KEY` | 视觉 API 的密钥 | `sk-your-api-key` |
81-
| `VISION_API_URL` | 视觉 API 的基础地址 | `https://your-api-endpoint/v1` |
82-
| `VISION_MODEL` | 视觉模型名称<br>(MiniMax 无需设置) | `your-vision-model` |
83-
| `VISION_API_TYPE` | 可选,强制指定 API 类型<br>`openai` / `minimax` | `minimax` |
84-
| `VISION_MAX_TOKENS` | 可选,视觉 API 返回的最大 token 数 | `4096` |
85-
| `VISION_FETCH_TIMEOUT_MS` | 可选,视觉 API fetch 超时毫秒数 | `60000` |
86-
| `VISION_MAX_IMAGES` | 可选,LRU 保留的最大图片数 | `200` |
78+
| 变量 | 说明 | 默认值 / 示例 |
79+
| ------------------------ | ----------------------------------------------------------------- | ------------------------------------------- |
80+
| `VISION_MODE` | 委派模式:`api`(默认)或 `subagent`。未设置时自动检测——有 `VISION_API_KEY` 则用 `api`,否则回退到 `subagent` | `subagent` |
81+
| `VISION_API_KEY` | 视觉 API 的密钥(`api` 模式必需) | `sk-your-api-key` |
82+
| `VISION_API_URL` | 视觉 API 的基础地址(`api` 模式必需) | `https://your-api-endpoint/v1` |
83+
| `VISION_MODEL` | 视觉模型名称<br>(MiniMax 无需设置) | `your-vision-model` |
84+
| `VISION_API_TYPE` | 可选,强制指定 API 类型<br>`openai` / `minimax` | `minimax` |
85+
| `VISION_SUBAGENT_NAME` | `subagent` 模式下的子代理标识符(默认 `image-reader`| `image-reader` |
86+
| `VISION_MAX_TOKENS` | 可选,视觉 API 返回的最大 token 数 | `4096` |
87+
| `VISION_FETCH_TIMEOUT_MS` | 可选,视觉 API fetch 超时毫秒数 | `60000` |
88+
| `VISION_MAX_IMAGES` | 可选,LRU 保留的最大图片数 | `200` |
8789

8890
> `VISION_API_URL`:OpenAI 兼容接口会自动补全 `/chat/completions`;MiniMax 会自动使用 `/v1/coding_plan/vlm` 端点。
8991
>
9092
> `VISION_API_TYPE`:默认自动检测(URL 含 `minimax` 自动切换),设此变量可显式指定。
9193
94+
### 委派模式
95+
96+
插件支持两种方式为非多模态模型获取图片描述:
97+
98+
#### `api` 模式(默认,原有行为)
99+
100+
`vision` 工具直接调用外部 VLM API。需配置 `VISION_API_KEY``VISION_API_URL`。支持 OpenAI 兼容接口和 MiniMax VLM。
101+
102+
```bash
103+
export VISION_MODE=api
104+
export VISION_API_KEY="sk-your-api-key"
105+
export VISION_API_URL="https://your-api-endpoint/v1"
106+
export VISION_MODEL="your-vision-model"
107+
```
108+
109+
#### `subagent` 模式(新增)
110+
111+
插件引导 LLM 通过 Task tool 将图片分析委托给一个具备视觉能力的子代理。无需外部 API 密钥——子代理使用 opencode 中配置的多模态模型(如 `opencode-go/minimax-m3`)。
112+
113+
```bash
114+
export VISION_MODE=subagent
115+
# 可选:覆盖子代理名称(默认 image-reader)
116+
# export VISION_SUBAGENT_NAME=image-reader
117+
```
118+
119+
**`subagent` 模式设置步骤:**
120+
121+
1.`~/.config/opencode/agent/image-reader.md` 创建子代理定义:
122+
123+
```markdown
124+
---
125+
description: Analyzes images and screenshots using a multimodal model. Use when the main agent cannot view images.
126+
mode: subagent
127+
model: opencode-go/minimax-m3
128+
permission:
129+
read: allow
130+
glob: allow
131+
list: allow
132+
bash: deny
133+
edit: deny
134+
---
135+
136+
You are a vision analyst. Read the image at the given path using the `read` tool and describe what you see.
137+
```
138+
139+
2. 重启 opencode。插件会自动:
140+
- 将粘贴的图片保存到 `/tmp/opencode-vision/image{N}/`
141+
- 注入系统提示引导非视觉模型委托子代理
142+
- 注入路径提示指名子代理
143+
144+
#### 自动回退
145+
146+
`VISION_MODE` 未设置时,插件自动判断:
147+
-`VISION_API_KEY` → 使用 `api` 模式
148+
-`VISION_API_KEY` → 回退到 `subagent` 模式
149+
150+
这意味着只要配置了视觉子代理,插件无需任何外部凭据即可开箱即用。
151+
92152
### 示例一:OpenAI 兼容接口(如阿里云 DashScope 通义千问)
93153

94154
**Windows 系统级配置:**

0 commit comments

Comments
 (0)