From ab45342349474e53e5e276f35a3ad73f5ce29b32 Mon Sep 17 00:00:00 2001 From: vonweller <154695311+vonweller@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:54:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E8=A7=89=E8=AF=86=E5=88=AB=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=98=AF=E5=90=A6=E6=98=AFOpenai=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 视觉识别添加是否是Openai协议的判断,当前测试openai全系使用无问题 --- config.yaml | 11 +++++++---- core/handle/VLHandle.py | 12 ++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/config.yaml b/config.yaml index fbe9dd9fd..26ee93ae3 100644 --- a/config.yaml +++ b/config.yaml @@ -58,6 +58,8 @@ prompt: | 请注意,要像一个人一样说话,请不要回复表情符号、代码、和xml标签。 当前时间是:{date_time},现在我正在和你进行语音聊天,我们开始吧。 如果用户希望结束对话,请在最后说“拜拜”或“再见”。 + 如果用户希望打开摄像头,等操作时等类型的要求时,你只需要回复正在打开 + 如果用户希望识别画面,识别图片,识别场景在干什么等类型的要求时 你只需要回复正在识别 # 使用完声音文件后删除文件(Delete the sound file when you are done using it) delete_audio: true @@ -77,7 +79,7 @@ selected_module: ASR: FunASR VAD: SileroVAD # 将根据配置名称对应的type调用实际的LLM适配器 - LLM: AliLLM + LLM: ChatGLMLLM # TTS将根据配置名称对应的type调用实际的TTS适配器 TTS: EdgeTTS @@ -106,7 +108,7 @@ LLM: # 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key #qwen-omni-turbo 可使用一系列阿里的视觉识别模型 base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 - model_name: qwen-turbo + model_name: qwen-omni-turbo api_key: 你的deepseek api key DeepSeekLLM: # 定义LLM API类型 @@ -119,10 +121,11 @@ LLM: # 定义LLM API类型 type: openai # glm-4-flash 是免费的,但是还是需要注册填写api_key的 + # glm-4v-plus 是视觉识别模型 # 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys - model_name: glm-4-flash + model_name: glm-4v-plus url: https://open.bigmodel.cn/api/paas/v4/ - api_key: 你的chat-glm api key + api_key: 你的deepseek api key OllamaLLM: # 定义LLM API类型 type: ollama diff --git a/core/handle/VLHandle.py b/core/handle/VLHandle.py index 966a2f226..3431e789c 100644 --- a/core/handle/VLHandle.py +++ b/core/handle/VLHandle.py @@ -4,8 +4,12 @@ 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": "图中描绘的是什么景象,请细致查看并描述"}, - ] + #print(text) + messages =[] + if conn.config["LLM"][conn.config["selected_module"]["LLM"]]['type']=='openai': + #print('当前openai接口协议LLM') + messages = [ + {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{text}"}, }, + {"type": "text", "text": "图中描绘的是什么景象,请细致查看并描述"}, + ] conn.executor.submit(conn.chat, messages)