From 3ba437c9370a2e8e74356a0a6b17cfbc23becc55 Mon Sep 17 00:00:00 2001 From: Chingfeng Li Date: Wed, 22 Oct 2025 14:53:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=B8=E9=87=8F=E5=8F=AF=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=9A=E5=85=81=E8=AE=B8=E8=87=AA=E5=AE=9A=E4=B9=89agent-bas?= =?UTF-8?q?e-prompt.txt=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/config.yaml | 3 +++ main/xiaozhi-server/core/utils/prompt_manager.py | 4 ++-- .../performance_tester/performance_tester_llm.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index 1fca578c..248be252 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -179,6 +179,9 @@ prompt: | - 长篇大论,叽叽歪歪 - 长时间严肃对话 +# 默认系统提示词模板文件 +prompt_template: agent-base-prompt.txt + # 结束语prompt end_prompt: enable: true # 是否开启结束语 diff --git a/main/xiaozhi-server/core/utils/prompt_manager.py b/main/xiaozhi-server/core/utils/prompt_manager.py index 4cbeefcb..0223f965 100644 --- a/main/xiaozhi-server/core/utils/prompt_manager.py +++ b/main/xiaozhi-server/core/utils/prompt_manager.py @@ -66,7 +66,7 @@ class PromptManager: def _load_base_template(self): """加载基础提示词模板""" try: - template_path = "agent-base-prompt.txt" + template_path = self.config.get("prompt_template", "agent-base-prompt.txt") cache_key = f"prompt_template:{template_path}" # 先从缓存获取 @@ -88,7 +88,7 @@ class PromptManager: self.base_prompt_template = template_content self.logger.bind(tag=TAG).debug("成功加载基础提示词模板并缓存") else: - self.logger.bind(tag=TAG).warning("未找到agent-base-prompt.txt文件") + self.logger.bind(tag=TAG).warning(f"未找到{template_path}文件") except Exception as e: self.logger.bind(tag=TAG).error(f"加载提示词模板失败: {e}") diff --git a/main/xiaozhi-server/performance_tester/performance_tester_llm.py b/main/xiaozhi-server/performance_tester/performance_tester_llm.py index 33430637..769cad6b 100644 --- a/main/xiaozhi-server/performance_tester/performance_tester_llm.py +++ b/main/xiaozhi-server/performance_tester/performance_tester_llm.py @@ -38,7 +38,7 @@ class LLMPerformanceTester: """加载系统提示词""" try: prompt_file = os.path.join( - os.path.dirname(os.path.dirname(__file__)), "agent-base-prompt.txt" + os.path.dirname(os.path.dirname(__file__)), self.config.get("prompt_template", "agent-base-prompt.txt") ) with open(prompt_file, "r", encoding="utf-8") as f: content = f.read()