From b6ba06ec974d7ff5f1239ee9ec8d6e90e2af206d Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sat, 8 Nov 2025 10:08:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=97=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=99=BA=E6=8E=A7=E5=8F=B0=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E6=9C=89=E5=8C=85=E5=90=AB"prompt=5Ftemplate?= =?UTF-8?q?"=E9=85=8D=E7=BD=AE=E4=BC=9A=E5=AF=BC=E8=87=B4self.config.get("?= =?UTF-8?q?prompt=5Ftemplate",=20"agent-base-prompt.txt")=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E4=B8=BANone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/utils/prompt_manager.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/main/xiaozhi-server/core/utils/prompt_manager.py b/main/xiaozhi-server/core/utils/prompt_manager.py index 1e247d07..5e3cb890 100644 --- a/main/xiaozhi-server/core/utils/prompt_manager.py +++ b/main/xiaozhi-server/core/utils/prompt_manager.py @@ -66,7 +66,9 @@ class PromptManager: def _load_base_template(self): """加载基础提示词模板""" try: - template_path = self.config.get("prompt_template", "agent-base-prompt.txt") + template_path = self.config.get("prompt_template", None) + if not template_path: + template_path = "agent-base-prompt.txt" cache_key = f"prompt_template:{template_path}" # 先从缓存获取 @@ -117,8 +119,12 @@ class PromptManager: def _get_current_time_info(self) -> tuple: """获取当前时间信息""" - from .current_time import get_current_date, get_current_weekday, get_current_lunar_date - + from .current_time import ( + get_current_date, + get_current_weekday, + get_current_lunar_date, + ) + today_date = get_current_date() today_weekday = get_current_weekday() lunar_date = get_current_lunar_date() + "\n" @@ -192,9 +198,7 @@ class PromptManager: try: # 获取最新的时间信息(不缓存) - today_date, today_weekday, lunar_date = ( - self._get_current_time_info() - ) + today_date, today_weekday, lunar_date = self._get_current_time_info() # 获取缓存的上下文信息 local_address = "" @@ -226,7 +230,8 @@ class PromptManager: emojiList=EMOJI_List, device_id=device_id, client_ip=client_ip, - *args, **kwargs + *args, + **kwargs, ) device_cache_key = f"device_prompt:{device_id}" self.cache_manager.set(