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()