更新VL视觉识别消息协议

更新VL视觉识别消息协议
目前的形式为:
vl_message = {
                "type": "VL",
                "image": base64(你的图片)
                "text":你的描述
                "version": 1,
                "transport": "websocket",
                "audio_params": {
                    "format": "opus",
                    "sample_rate": 16000,
                    "channels": 1,
                    "frame_duration": 60
                }
This commit is contained in:
vonweller 2025-03-07 15:49:51 +08:00
parent 3f9242acee
commit a2c14b6ed0
2 changed files with 6 additions and 6 deletions

View file

@ -3,13 +3,13 @@ from config.logger import setup_logging
logger = setup_logging()
async def handleVLMessage(conn, text):
async def handleVLMessage(conn, mesage):
#print(text)
messages =[]
if conn.config["LLM"][conn.config["selected_module"]["LLM"]]['type']=='openai':
#print('当前openai接口协议LLM')
print('当前openai接口协议LLM')
messages = [
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{text}"}, },
{"type": "text", "text": "图中描绘的是什么景象,请细致查看并描述"},
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{mesage['image']}"}, },
{"type": "text", "text": "图中描绘的是什么景象,请细致查看并描述"+mesage['text']},
]
conn.executor.submit(conn.chat, messages)

View file

@ -41,9 +41,9 @@ async def handleTextMessage(conn, message):
elif msg_json["type"] == "iot":
if "descriptors" in msg_json:
await handleIotDescriptors(conn, msg_json["descriptors"])
####视觉识别添加能力 msg中应该包含图片数据
####视觉识别添加能力 image中应该包含图片数据
elif msg_json["type"] == "VL":
await handleVLMessage(conn, msg_json['msg'])
await handleVLMessage(conn, msg_json)
except json.JSONDecodeError:
await conn.websocket.send(message)