From 4342f87515ca04fd79833344b6a48a8c260ec66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E5=87=A4=E7=A7=91=E6=8A=80?= Date: Mon, 17 Mar 2025 17:32:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0function=20call=20action?= =?UTF-8?q?=E7=9A=84=20Error=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/connection.py | 7 ++++--- main/xiaozhi-server/plugins_func/register.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index a87bccb6c..7e0a83701 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -450,7 +450,7 @@ class ConnectionHandler: future = self.executor.submit(self.speak_and_play, text, text_index) self.tts_queue.put(future) self.dialogue.put(Message(role="assistant", content=text)) - if result.action == Action.REQLLM: # 调用函数后再请求llm生成回复 + elif result.action == Action.REQLLM: # 调用函数后再请求llm生成回复 text = result.result if text is not None and len(text) > 0: @@ -465,9 +465,10 @@ class ConnectionHandler: self.dialogue.put(Message(role="tool", tool_call_id=function_id, content=text)) self.chat_with_function_calling(text, tool_call=True) - if result.action == Action.NOTFOUND: + elif result.action == Action.NOTFOUND: + text = result.response + else: text = result.response - def _tts_priority_thread(self): diff --git a/main/xiaozhi-server/plugins_func/register.py b/main/xiaozhi-server/plugins_func/register.py index 37759d629..ccb03b441 100644 --- a/main/xiaozhi-server/plugins_func/register.py +++ b/main/xiaozhi-server/plugins_func/register.py @@ -19,6 +19,7 @@ class ToolType(Enum): class Action(Enum): + ERROR = (-1, "错误") NOTFOUND = (0, "没有找到函数") NONE = (1, "啥也不干") RESPONSE = (2, "直接回复")