Add input image to product protocol
This commit is contained in:
@@ -69,13 +69,43 @@ ws://<host>:<port>/ws-product
|
||||
|
||||
`interrupt` 默认为 `true`,会打断当前正在播放的 bot 语音。
|
||||
|
||||
### 4. 取消当前回复
|
||||
### 4. 发送摄像头图片(可选)
|
||||
|
||||
客户端可发送一帧摄像头截图,让 LLM 基于图片内容回复。服务端会把图片追加到 Pipecat LLM context,并立即触发一次 LLM 推理;后续回复仍通过现有的 `response.text.*` 与 `response.audio.*` 事件返回。
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "input.image",
|
||||
"image": "<base64 编码的 JPEG/PNG/WebP 图片字节>",
|
||||
"mime_type": "image/jpeg",
|
||||
"width": 640,
|
||||
"height": 360,
|
||||
"text": "请根据这张摄像头画面回答用户的问题。",
|
||||
"user_id": "product-user",
|
||||
"append_to_context": true
|
||||
}
|
||||
```
|
||||
|
||||
字段说明:
|
||||
|
||||
| 字段 | 说明 |
|
||||
|------|------|
|
||||
| `image` / `data` | 必填,图片字节的 base64;也兼容 `data:image/...;base64,...` data URL |
|
||||
| `mime_type` / `media_type` | 可选,默认 `image/jpeg`;支持 `image/jpeg`、`image/png`、`image/webp` |
|
||||
| `width`、`height` | 必填,图片像素尺寸,必须为正整数 |
|
||||
| `text` | 可选,随图片一起进入 LLM 的问题/提示词 |
|
||||
| `user_id` | 可选,默认 `product-user` |
|
||||
| `append_to_context` | 可选,默认 `true`;为 `true` 时图片会进入 LLM context 并触发回复 |
|
||||
|
||||
建议发送压缩后的截图而不是持续视频流,例如 640px 宽、JPEG quality 0.75 左右。单张图片最大 8 MB。
|
||||
|
||||
### 5. 取消当前回复
|
||||
|
||||
```json
|
||||
{"type": "response.cancel"}
|
||||
```
|
||||
|
||||
### 5. 结束会话
|
||||
### 6. 结束会话
|
||||
|
||||
```json
|
||||
{"type": "session.stop", "reason": "done"}
|
||||
|
||||
Reference in New Issue
Block a user