mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-24 16:13:54 +08:00
perf:
1、新增工具调用Action枚举RECORD,通过完整的三段式 assistant(tool_calls) → tool → assistant(response)让模型准确学习到工具调用的正确行为,优化play_music的工具调用枚举NONE变更为RECORD,优化解决音乐播放工具调用缺陷问题。 2、处理悬空 tool_calls问题。 3、去除工具提示词强化注入逻辑。
This commit is contained in:
@@ -67,7 +67,7 @@ def play_music(conn: "ConnectionHandler", song_name: str):
|
||||
task.add_done_callback(handle_done)
|
||||
|
||||
return ActionResponse(
|
||||
action=Action.NONE, result="指令已接收", response="正在为您播放音乐"
|
||||
action=Action.RECORD, result="指令已接收", response="正在为您播放音乐"
|
||||
)
|
||||
except Exception as e:
|
||||
conn.logger.bind(tag=TAG).error(f"处理音乐意图错误: {e}")
|
||||
@@ -217,7 +217,7 @@ async def play_local_music(conn: "ConnectionHandler", specific_file=None):
|
||||
conn.logger.bind(tag=TAG).error(f"选定的音乐文件不存在: {music_path}")
|
||||
return
|
||||
text = _get_random_play_prompt(selected_music)
|
||||
conn.dialogue.put(Message(role="assistant", content=text))
|
||||
# conn.dialogue.put(Message(role="assistant", content=text))
|
||||
|
||||
if conn.intent_type == "intent_llm":
|
||||
conn.tts.tts_text_queue.put(
|
||||
|
||||
@@ -28,6 +28,7 @@ class Action(Enum):
|
||||
NONE = (1, "啥也不干")
|
||||
RESPONSE = (2, "直接回复")
|
||||
REQLLM = (3, "调用函数后再请求llm生成回复")
|
||||
RECORD = (4, "记录工具调用到对话历史,不调用LLM")
|
||||
|
||||
def __init__(self, code, message):
|
||||
self.code = code
|
||||
|
||||
Reference in New Issue
Block a user