xiaozhi-esp32-server/core/handle/VLHandle.py
vonweller 831fedc65a 给服务端添加视觉识别模型能力
为服务端添加视觉识别的能力
客户端只需要发送的消息类型:
            vl_message = {
                "type": "VL",
                "msg": base64(你的图片)
                "version": 1,
                "transport": "websocket",
                "audio_params": {
                    "format": "opus",
                    "sample_rate": 16000,
                    "channels": 1,
                    "frame_duration": 60
                }
2025-03-04 17:44:49 +08:00

12 lines
427 B
Python

import json
from config.logger import setup_logging
logger = setup_logging()
async def handleVLMessage(conn, text):
messages = [
{"type": "image_url","image_url": {"url": f"data:image/png;base64,{text}"},},
{"type": "text", "text": "图中描绘的是什么景象,请细致查看并描述"},
]
conn.executor.submit(conn.chat, messages)
await conn.websocket.send(json.dumps(conn.welcome_msg))