From a2c14b6ed030fb67fd926c86d7e9cc8908a79c3f Mon Sep 17 00:00:00 2001 From: vonweller <154695311+vonweller@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0VL=E8=A7=86=E8=A7=89=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E6=B6=88=E6=81=AF=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新VL视觉识别消息协议 目前的形式为: vl_message = { "type": "VL", "image": base64(你的图片) "text":你的描述 "version": 1, "transport": "websocket", "audio_params": { "format": "opus", "sample_rate": 16000, "channels": 1, "frame_duration": 60 } --- core/handle/VLHandle.py | 8 ++++---- core/handle/textHandle.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/handle/VLHandle.py b/core/handle/VLHandle.py index 3431e789c..36a10da07 100644 --- a/core/handle/VLHandle.py +++ b/core/handle/VLHandle.py @@ -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) diff --git a/core/handle/textHandle.py b/core/handle/textHandle.py index 6dff02303..c5182e4f3 100644 --- a/core/handle/textHandle.py +++ b/core/handle/textHandle.py @@ -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)