This commit is contained in:
vonweller 2025-03-05 10:35:00 +00:00 committed by GitHub
commit e513b937df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 32 additions and 4 deletions

View file

@ -58,6 +58,8 @@ prompt: |
请注意,要像一个人一样说话,请不要回复表情符号、代码、和xml标签。 请注意,要像一个人一样说话,请不要回复表情符号、代码、和xml标签。
当前时间是:{date_time},现在我正在和你进行语音聊天,我们开始吧。 当前时间是:{date_time},现在我正在和你进行语音聊天,我们开始吧。
如果用户希望结束对话,请在最后说“拜拜”或“再见”。 如果用户希望结束对话,请在最后说“拜拜”或“再见”。
如果用户希望打开摄像头等类型的要求时,你只需要回复“好的正在打开”
如果用户希望识别画面,识别图片,识别场景等类型的要求时“你只需要回复正在识别”
# 使用完声音文件后删除文件(Delete the sound file when you are done using it) # 使用完声音文件后删除文件(Delete the sound file when you are done using it)
delete_audio: true delete_audio: true
@ -112,8 +114,9 @@ LLM:
# 定义LLM API类型 # 定义LLM API类型
type: openai type: openai
# 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key # 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key
#qwen-omni-turbo 可使用一系列阿里的视觉识别模型
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
model_name: qwen-turbo model_name: qwen-omni-turbo
api_key: 你的deepseek api key api_key: 你的deepseek api key
DeepSeekLLM: DeepSeekLLM:
# 定义LLM API类型 # 定义LLM API类型
@ -126,10 +129,11 @@ LLM:
# 定义LLM API类型 # 定义LLM API类型
type: openai type: openai
# glm-4-flash 是免费的,但是还是需要注册填写api_key的 # glm-4-flash 是免费的,但是还是需要注册填写api_key的
# glm-4v-plus 是视觉识别模型
# 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys # 可在这里找到你的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/ url: https://open.bigmodel.cn/api/paas/v4/
api_key: 你的chat-glm api key api_key: 你的deepseek api key
OllamaLLM: OllamaLLM:
# 定义LLM API类型 # 定义LLM API类型
type: ollama type: ollama

15
core/handle/VLHandle.py Normal file
View file

@ -0,0 +1,15 @@
import json
from config.logger import setup_logging
logger = setup_logging()
async def handleVLMessage(conn, 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)

View file

@ -2,6 +2,7 @@ from config.logger import setup_logging
import json import json
from core.handle.abortHandle import handleAbortMessage from core.handle.abortHandle import handleAbortMessage
from core.handle.helloHandle import handleHelloMessage from core.handle.helloHandle import handleHelloMessage
from core.handle.VLHandle import handleVLMessage
from core.handle.receiveAudioHandle import startToChat from core.handle.receiveAudioHandle import startToChat
from core.handle.iotHandle import handleIotDescriptors from core.handle.iotHandle import handleIotDescriptors
@ -40,5 +41,9 @@ async def handleTextMessage(conn, message):
elif msg_json["type"] == "iot": elif msg_json["type"] == "iot":
if "descriptors" in msg_json: if "descriptors" in msg_json:
await handleIotDescriptors(conn, msg_json["descriptors"]) await handleIotDescriptors(conn, msg_json["descriptors"])
####视觉识别添加能力 msg中应该包含图片数据
elif msg_json["type"] == "VL":
await handleVLMessage(conn, msg_json['msg'])
except json.JSONDecodeError: except json.JSONDecodeError:
await conn.websocket.send(message) await conn.websocket.send(message)

View file

@ -23,7 +23,10 @@ class LLMProvider(LLMProviderBase):
responses = self.client.chat.completions.create( responses = self.client.chat.completions.create(
model=self.model_name, model=self.model_name,
messages=dialogue, messages=dialogue,
stream=True # 设置输出数据的模态,当前支持["text"]
modalities=["text"],
stream=True,
stream_options={"include_usage": True}
) )
is_active = True is_active = True

View file

@ -1,3 +1,4 @@
#pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
pyyml==0.0.2 pyyml==0.0.2
torch==2.2.2 torch==2.2.2
silero_vad==5.1.2 silero_vad==5.1.2