mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
Merge 3f9242acee into 8b151d07c2
This commit is contained in:
commit
e513b937df
5 changed files with 32 additions and 4 deletions
10
config.yaml
10
config.yaml
|
|
@ -58,6 +58,8 @@ prompt: |
|
|||
请注意,要像一个人一样说话,请不要回复表情符号、代码、和xml标签。
|
||||
当前时间是:{date_time},现在我正在和你进行语音聊天,我们开始吧。
|
||||
如果用户希望结束对话,请在最后说“拜拜”或“再见”。
|
||||
如果用户希望打开摄像头等类型的要求时,你只需要回复“好的正在打开”
|
||||
如果用户希望识别画面,识别图片,识别场景等类型的要求时“你只需要回复正在识别”
|
||||
# 使用完声音文件后删除文件(Delete the sound file when you are done using it)
|
||||
delete_audio: true
|
||||
|
||||
|
|
@ -112,8 +114,9 @@ LLM:
|
|||
# 定义LLM API类型
|
||||
type: openai
|
||||
# 可在这里找到你的 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类型
|
||||
|
|
@ -126,10 +129,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
|
||||
|
|
|
|||
15
core/handle/VLHandle.py
Normal file
15
core/handle/VLHandle.py
Normal 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)
|
||||
|
|
@ -2,6 +2,7 @@ from config.logger import setup_logging
|
|||
import json
|
||||
from core.handle.abortHandle import handleAbortMessage
|
||||
from core.handle.helloHandle import handleHelloMessage
|
||||
from core.handle.VLHandle import handleVLMessage
|
||||
from core.handle.receiveAudioHandle import startToChat
|
||||
from core.handle.iotHandle import handleIotDescriptors
|
||||
|
||||
|
|
@ -40,5 +41,9 @@ async def handleTextMessage(conn, message):
|
|||
elif msg_json["type"] == "iot":
|
||||
if "descriptors" in msg_json:
|
||||
await handleIotDescriptors(conn, msg_json["descriptors"])
|
||||
####视觉识别添加能力 msg中应该包含图片数据
|
||||
elif msg_json["type"] == "VL":
|
||||
await handleVLMessage(conn, msg_json['msg'])
|
||||
|
||||
except json.JSONDecodeError:
|
||||
await conn.websocket.send(message)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ class LLMProvider(LLMProviderBase):
|
|||
responses = self.client.chat.completions.create(
|
||||
model=self.model_name,
|
||||
messages=dialogue,
|
||||
stream=True
|
||||
# 设置输出数据的模态,当前支持["text"]
|
||||
modalities=["text"],
|
||||
stream=True,
|
||||
stream_options={"include_usage": True}
|
||||
)
|
||||
|
||||
is_active = True
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
|
||||
pyyml==0.0.2
|
||||
torch==2.2.2
|
||||
silero_vad==5.1.2
|
||||
|
|
|
|||
Loading…
Reference in a new issue