From 4c91bffcc70a35a192d2e5b6c15e8368ca9f6308 Mon Sep 17 00:00:00 2001 From: Jad Date: Sun, 30 Mar 2025 12:46:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20=E5=8A=A0=E8=BD=BD=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=94=B9=E4=B8=BA=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=89=A7=E8=A1=8C=20#559?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/connection.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 0f4e2a70..ff3c816a 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -102,6 +102,19 @@ class ConnectionHandler: if self.config["selected_module"]["Intent"] == 'function_call': self.use_function_call_mode = True + try: + # 加载插件 + if self.use_function_call_mode: + self.func_handler = FunctionHandler(self) + self.logger.bind(tag=TAG).info("初始化FunctionHandler成功") + else: + self.func_handler = None + self.logger.bind(tag=TAG).info("未启用function_call模式,跳过FunctionHandler初始化") + except Exception as e: + self.logger.bind(tag=TAG).error(f"初始化FunctionHandler失败: {str(e)}") + self.func_handler = None + self.use_function_call_mode = False + self.mcp_manager = MCPManager(self) async def handle_connection(self, ws): @@ -191,9 +204,6 @@ class ConnectionHandler: self.prompt = self.private_config.private_config.get("prompt", self.prompt) self.dialogue.put(Message(role="system", content=self.prompt)) - """加载插件""" - self.func_handler = FunctionHandler(self) - """加载记忆""" device_id = self.headers.get("device-id", None) self.memory.init_memory(device_id, self.llm)