Update mcp-vision-integration.md

This commit is contained in:
Alireza Jahanshahlou 2025-10-12 17:35:00 +03:30 committed by GitHub
parent 18d882a0d7
commit a20b8fa3a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,24 +1,24 @@
# 视觉模型使用指南 # Visual Model Usage Guide
本教程分为两部分: This tutorial is divided into two parts:
- 第一部分:单模块运行xiaozhi-server开启视觉模型 - Part 1: Run xiaozhi-server as a single module to start the visual model
- 第二部分:全模块运行时,如何开启视觉模型 - Part 2: How to enable the visual model when all modules are running
开启视觉模型前,你需要准备三件事: Before starting the visual model, you need to prepare three things:
- 你需要准备一台带摄像头的设备,而且这台设备已经在虾哥仓库里,实现了调用摄像头功能。例如`立创·实战派ESP32-S3开发板` - You need to prepare a device with a camera, and this device is already in the Xiage warehouse and has the camera function enabled. For example, the LiChuang Practical ESP32-S3 Development Board
- 你设备固件的版本升级到1.6.6及以上 - Upgrade your device's firmware to version 1.6.6 or above
- 你已经成功跑通基础对话模块 - You have successfully completed the basic dialogue module
## 单模块运行xiaozhi-server开启视觉模型 ## Single module running xiaozhi-server to start the visual model
### 第一步确认网络 ### Step 1: Confirm the network
由于视觉模型会默认启动8003端口。 Because the visual model will start port 8003 by default.
如果你是docker运行,请确认一下你的`docker-compose.yml`是否放了`8003`端口,如果没有就更新最新的`docker-compose.yml`文件 If you are running docker, please confirm whether your `docker-compose.yml` has the `8003` port. If not, update the latest `docker-compose.yml` file
如果你是源码运行,确认防火墙是否放行`8003`端口 If you are running from source code, make sure your firewall is allowing access to port 8003.
### 第二步选择你的视觉模型 ### Step 2: Choose your visual model
打开你的`data/.config.yaml`文件,设置你的`selected_module.VLLM`设置为某个视觉模型。目前我们已经支持`openai`类型接口的视觉模型。`ChatGLMVLLM`就是其中一款兼容`openai`的模型。 Open your `data/.config.yaml` file and set `selected_module.VLLM` to a visual model. Currently, we support visual models with `openai` type interfaces. `ChatGLMVLLM` is one of the models compatible with `openai`.
``` ```
selected_module: selected_module:
@ -31,141 +31,141 @@ selected_module:
Intent: .. Intent: ..
``` ```
假设我们使用`ChatGLMVLLM`作为视觉模型,那我们需要先登录[智谱AI](https://bigmodel.cn/usercenter/proj-mgmt/apikeys)网站,申请密钥。如果你之前已经申请过了密钥,可以复用这个密钥。 Assuming we use `ChatGLMVLLM` as the visual model, we need to log in to the [Zhipu AI](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) website to apply for a key. If you have already applied for a key, you can reuse it.
在你的配置文件中,增加这个配置,如果已经有了这个配置,就设置好你的api_key。 In your configuration file, add this configuration. If you already have this configuration, set your api_key.
``` ```
VLLM: VLLM:
ChatGLMVLLM: ChatGLMVLLM:
api_key: 你的api_key api_key: your api_key
``` ```
### 第三步启动xiaozhi-server服务 ### The third step is to start the xiaozhi-server service
如果你是源码,就输入命令启动 If you are using source code, enter the command to start
``` ```
python app.py python app.py
``` ```
如果你是docker运行,就重启容器 If you are running in docker, restart the container
``` ```
docker restart xiaozhi-esp32-server docker restart xiaozhi-esp32-server
``` ```
启动后会输出以下内容的日志。 After startup, the following log will be output.
``` ```
2025-06-01 **** - OTA接口是 http://192.168.4.7:8003/xiaozhi/ota/ 2025-06-01 **** - OTA interface is http://192.168.4.7:8003/xiaozhi/ota/
2025-06-01 **** - 视觉分析接口是 http://192.168.4.7:8003/mcp/vision/explain 2025-06-01 **** - The visual analysis interface is http://192.168.4.7:8003/mcp/vision/explain
2025-06-01 **** - Websocket地址是 ws://192.168.4.7:8000/xiaozhi/v1/ 2025-06-01 **** - Websocket address is ws://192.168.4.7:8000/xiaozhi/v1/
2025-06-01 **** - =======上面的地址是websocket协议地址,请勿用浏览器访问======= 2025-06-01 **** - =======The above address is a websocket protocol address, please do not access it with a browser=======
2025-06-01 **** - 如想测试websocket请用谷歌浏览器打开test目录下的test_page.html 2025-06-01 **** - If you want to test websocket, please use Google Chrome to open the test_page.html in the test directory.
2025-06-01 **** - ============================================================= 2025-06-01 **** - =============================================================
``` ```
启动后,使用使用浏览器打开日志里`视觉分析接口`连接。看看输出了什么?如果你是linux,没有浏览器,你可以执行这个命令: After startup, use a browser to open the `Visual Analysis Interface` connection in the log to see what is output. If you are using Linux and don't have a browser, you can execute this command:
``` ```
curl -i 你的视觉分析接口 curl -i your visual analysis interface
``` ```
正常来说会这样显示 Normally it will display like this
``` ```
MCP Vision 接口运行正常,视觉解释接口地址是:http://xxxx:8003/mcp/vision/explain The MCP Vision interface is running normally. The visual explanation interface address is: http://xxxx:8003/mcp/vision/explain
``` ```
请注意,如果你是公网部署,或者docker部署,一定要改一下你的`data/.config.yaml`里这个配置 Please note that if you are deploying on the public network or in docker, you must change the configuration in your `data/.config.yaml`
``` ```
server: server:
vision_explain: http://你的ip或者域名:端口号/mcp/vision/explain vision_explain: http://your ip or domain name:port number/mcp/vision/explain
``` ```
为什么呢?因为视觉解释接口需要下发到设备,如果你的地址是局域网地址,或者是docker内部地址,设备是无法访问的。 Why? Because the visual interpretation interface needs to be sent to the device. If your address is a LAN address or an internal address of Docker, the device cannot be accessed.
假设你的公网地址是`111.111.111.111`,那么`vision_explain`应该这么配 Assuming your public network address is `111.111.111.111`, then `vision_explain` should be configured like this:
``` ```
server: server:
vision_explain: http://111.111.111.111:8003/mcp/vision/explain vision_explain: http://111.111.111.111:8003/mcp/vision/explain
``` ```
如果你的MCP Vision 接口运行正常,且你也试着用浏览器访问正常打开下发的`视觉解释接口地址`,请继续下一步 If your MCP Vision interface is running normally and you have also tried to use a browser to access the `visual interpretation interface address` that is normally opened, please continue to the next step
### 第四步 设备唤醒开启 ### Step 4: Device wake-up and start
对设备说“请打开摄像头,说你你看到了什么” Say to the device "Please turn on the camera and tell me what you see"
留意xiaozhi-server的日志输出,看看有没有报错。 Pay attention to the log output of xiaozhi-server to see if there are any errors.
## 全模块运行时,如何开启视觉模型 ## How to enable the visual model when running all modules
### 第一步 确认网络 ### Step 1: Confirm the network
由于视觉模型会默认启动8003端口。 Because the visual model will start port 8003 by default.
如果你是docker运行,请确认一下你的`docker-compose_all.yml`是否映射了`8003`端口,如果没有就更新最新的`docker-compose_all.yml`文件 If you are running docker, please confirm whether your `docker-compose_all.yml` has mapped `8003` port. If not, update the latest `docker-compose_all.yml` file
如果你是源码运行,确认防火墙是否放行`8003`端口 If you are running from source code, make sure your firewall is allowing access to port 8003.
### 第二步 确认你配置文件 ### Step 2 Confirm your configuration file
打开你的`data/.config.yaml`文件,确认一下你的配置文件的结构,是否和`data/config_from_api.yaml`一样。如果不一样,或缺少某项,请补齐。 Open your `data/.config.yaml` file and confirm whether the structure of your configuration file is the same as `data/config_from_api.yaml`. If it is different or missing, please fill it in.
### 第三步 配置视觉模型密钥 ### The third step is to configure the visual model key
那我们需要先登录[智谱AI](https://bigmodel.cn/usercenter/proj-mgmt/apikeys)网站,申请密钥。如果你之前已经申请过了密钥,可以复用这个密钥。 Then we need to log in to the [Zhipu AI](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) website to apply for a key. If you have already applied for a key, you can reuse it.
登录`智控台`,顶部菜单点击`模型配置`,在左侧栏点击`视觉打语言模型`,找到`VLLM_ChatGLMVLLM`,点击修改按钮,在弹框中,在`API密钥`输入你密钥,点击保存。 Log in to the Smart Console, click Model Configuration on the top menu, click Vision and Language Model on the left sidebar, find VLLM_ChatGLMVLLM, click Modify, enter your key in the API Key field, and click Save.
保存成功后,去到你需要测试的智能体哪里,点击`配置角色`,在打开的内容里,查看`视觉大语言模型(VLLM)`是否选择了刚才的视觉模型。点击保存。 After successfully saving, go to the agent you want to test, click Configure Actor, and in the context that opens, check that the Vision Large Language Model (VLLM) is selected. Click Save.
### 第三步 启动xiaozhi-server模块 ### The third step is to start the xiaozhi-server module
如果你是源码,就输入命令启动 If you are using source code, enter the command to start
``` ```
python app.py python app.py
``` ```
如果你是docker运行,就重启容器 If you are running in docker, restart the container
``` ```
docker restart xiaozhi-esp32-server docker restart xiaozhi-esp32-server
``` ```
启动后会输出以下内容的日志。 After startup, the following log will be output.
``` ```
2025-06-01 **** - 视觉分析接口是 http://192.168.4.7:8003/mcp/vision/explain 2025-06-01 **** - The visual analysis interface is http://192.168.4.7:8003/mcp/vision/explain
2025-06-01 **** - Websocket地址是 ws://192.168.4.7:8000/xiaozhi/v1/ 2025-06-01 **** - Websocket address is ws://192.168.4.7:8000/xiaozhi/v1/
2025-06-01 **** - =======上面的地址是websocket协议地址,请勿用浏览器访问======= 2025-06-01 **** - =======The above address is a websocket protocol address, please do not access it with a browser=======
2025-06-01 **** - 如想测试websocket请用谷歌浏览器打开test目录下的test_page.html 2025-06-01 **** - If you want to test websocket, please use Google Chrome to open the test_page.html in the test directory.
2025-06-01 **** - ============================================================= 2025-06-01 **** - =============================================================
``` ```
启动后,使用使用浏览器打开日志里`视觉分析接口`连接。看看输出了什么?如果你是linux,没有浏览器,你可以执行这个命令: After startup, use a browser to open the `Visual Analysis Interface` connection in the log to see what is output. If you are using Linux and don't have a browser, you can execute this command:
``` ```
curl -i 你的视觉分析接口 curl -i your visual analysis interface
``` ```
正常来说会这样显示 Normally it will display like this
``` ```
MCP Vision 接口运行正常,视觉解释接口地址是:http://xxxx:8003/mcp/vision/explain The MCP Vision interface is running normally. The visual explanation interface address is: http://xxxx:8003/mcp/vision/explain
``` ```
请注意,如果你是公网部署,或者docker部署,一定要改一下你的`data/.config.yaml`里这个配置 Please note that if you are deploying on the public network or in docker, you must change the configuration in your `data/.config.yaml`
``` ```
server: server:
vision_explain: http://你的ip或者域名:端口号/mcp/vision/explain vision_explain: http://your ip or domain name:port number/mcp/vision/explain
``` ```
为什么呢?因为视觉解释接口需要下发到设备,如果你的地址是局域网地址,或者是docker内部地址,设备是无法访问的。 Why? Because the visual interpretation interface needs to be sent to the device. If your address is a LAN address or an internal address of Docker, the device cannot be accessed.
假设你的公网地址是`111.111.111.111`,那么`vision_explain`应该这么配 Assuming your public network address is `111.111.111.111`, then `vision_explain` should be configured like this:
``` ```
server: server:
vision_explain: http://111.111.111.111:8003/mcp/vision/explain vision_explain: http://111.111.111.111:8003/mcp/vision/explain
``` ```
如果你的MCP Vision 接口运行正常,且你也试着用浏览器访问正常打开下发的`视觉解释接口地址`,请继续下一步 If your MCP Vision interface is running normally and you have also tried to use a browser to access the `visual interpretation interface address` that is normally opened, please continue to the next step
### 第四步 设备唤醒开启 ### Step 4: Device wake-up and start
对设备说“请打开摄像头,说你你看到了什么” Say to the device "Please turn on the camera and tell me what you see"
留意xiaozhi-server的日志输出,看看有没有报错。 Pay attention to the log output of xiaozhi-server to see if there are any errors.