mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
update:function call最优设置成doubao-pro-32k-functioncall-241028
This commit is contained in:
parent
63b326b01c
commit
d789c7f393
3 changed files with 31 additions and 26 deletions
|
|
@ -73,8 +73,9 @@ selected_module:
|
|||
# TTS将根据配置名称对应的type调用实际的TTS适配器
|
||||
TTS: EdgeTTS
|
||||
# 记忆模块,默认使用本地压缩记忆,如果想使用超长记忆,推荐使用mem0ai
|
||||
Memory: mem_local_short
|
||||
Memory: nomem
|
||||
# 意图识别模块,默认不开启。开启后,可以播放音乐、控制音量、识别退出指令
|
||||
# 如果意图识别设置成 function_call,建议使用:DoubaoLLM,推荐把的model_name设置为:doubao-pro-32k-functioncall-241028
|
||||
Intent: nointent
|
||||
|
||||
# 意图识别,是用于理解用户意图的模块,例如:播放音乐
|
||||
|
|
@ -86,7 +87,6 @@ Intent:
|
|||
intent_llm:
|
||||
type: intent_llm
|
||||
# 意图识别使用function_call,缺点:需要所选择的LLM支持function_call,优点:按需调用工具、速度快
|
||||
# 新手使用function_call,建议使用:AliLLM,并把的model_name设置为:qwen-max
|
||||
function_call:
|
||||
type: function_call
|
||||
|
||||
|
|
@ -129,6 +129,13 @@ LLM:
|
|||
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
model_name: qwen-turbo
|
||||
api_key: 你的deepseek web key
|
||||
DoubaoLLM:
|
||||
# 定义LLM API类型
|
||||
type: openai
|
||||
# 可在这里开通 https://console.volcengine.com/ark/region:ark+cn-beijing/model/detail?Id=doubao-pro-32k&projectName=undefined
|
||||
base_url: https://ark.cn-beijing.volces.com/api/v3
|
||||
model_name: doubao-pro-32k-functioncall-241028
|
||||
api_key: 你的doubao web key
|
||||
DeepSeekLLM:
|
||||
# 定义LLM API类型
|
||||
type: openai
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ class ConnectionHandler:
|
|||
|
||||
self.logger.bind(tag=TAG).info(f"use_function_call_mode:{self.use_function_call_mode}")
|
||||
|
||||
|
||||
async def handle_connection(self, ws):
|
||||
try:
|
||||
# 获取并验证headers
|
||||
|
|
@ -214,7 +213,6 @@ class ConnectionHandler:
|
|||
return False
|
||||
return not self.is_device_verified
|
||||
|
||||
|
||||
def chat(self, query):
|
||||
if self.isNeedAuth():
|
||||
self.llm_finish_task = True
|
||||
|
|
@ -256,7 +254,7 @@ class ConnectionHandler:
|
|||
current_text = full_text[processed_chars:] # 从未处理的位置开始
|
||||
|
||||
# 查找最后一个有效标点
|
||||
punctuations = ("。", "?", "!", "?", "!", ";", ";", ":", ":")
|
||||
punctuations = ("。", "?", "!", ";", ":")
|
||||
last_punct_pos = -1
|
||||
for punct in punctuations:
|
||||
pos = current_text.rfind(punct)
|
||||
|
|
@ -318,7 +316,7 @@ class ConnectionHandler:
|
|||
future = asyncio.run_coroutine_threadsafe(self.memory.query_memory(query), self.loop)
|
||||
memory_str = future.result()
|
||||
|
||||
#self.logger.bind(tag=TAG).info(f"记忆内容: {memory_str}")
|
||||
# self.logger.bind(tag=TAG).info(f"记忆内容: {memory_str}")
|
||||
|
||||
# 使用支持functions的streaming接口
|
||||
llm_responses = self.llm.response_with_functions(
|
||||
|
|
@ -351,7 +349,7 @@ class ConnectionHandler:
|
|||
current_text = full_text[processed_chars:] # 从未处理的位置开始
|
||||
|
||||
# 查找最后一个有效标点
|
||||
punctuations = ("。", "?", "!", "?", "!", ";", ";", ":", ":")
|
||||
punctuations = ("。", "?", "!", ";", ":")
|
||||
last_punct_pos = -1
|
||||
for punct in punctuations:
|
||||
pos = current_text.rfind(punct)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class LLMProvider(LLMProviderBase):
|
|||
}
|
||||
|
||||
if current_function_call:
|
||||
logger.bind(tag=TAG).debug(f"ollama Function call detected: {current_function_call}")
|
||||
logger.bind(tag=TAG).debug(f"openai Function call detected: {current_function_call}")
|
||||
yield {"type": "function_call", "function_call": current_function_call}
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Reference in a new issue