From e8d0bb0c5485f63d0d30604c0c028d3956d23d3b Mon Sep 17 00:00:00 2001 From: 3030332422 <3030332422@qq.com> Date: Thu, 18 Dec 2025 16:34:37 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E6=8C=89=E6=A8=A1=E6=9D=BF=E6=8C=89?= =?UTF-8?q?=E9=9C=80=E8=8E=B7=E5=8F=96=EF=BC=88=E4=BD=8D=E7=BD=AE/?= =?UTF-8?q?=E5=A4=A9=E6=B0=94/=E5=8A=A8=E6=80=81=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=87=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/utils/prompt_manager.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/main/xiaozhi-server/core/utils/prompt_manager.py b/main/xiaozhi-server/core/utils/prompt_manager.py index 78c63483..70f14d92 100644 --- a/main/xiaozhi-server/core/utils/prompt_manager.py +++ b/main/xiaozhi-server/core/utils/prompt_manager.py @@ -184,10 +184,25 @@ class PromptManager: def update_context_info(self, conn, client_ip: str): """同步更新上下文信息""" try: - # 获取位置信息(使用全局缓存) - local_address = self._get_location_info(client_ip) - # 获取天气信息(使用全局缓存) - self._get_weather_info(conn, local_address) + local_address = "" + if ( + client_ip + and self.base_prompt_template + and ( + "local_address" in self.base_prompt_template + or "weather_info" in self.base_prompt_template + ) + ): + # 获取位置信息(使用全局缓存) + local_address = self._get_location_info(client_ip) + + if ( + self.base_prompt_template + and "weather_info" in self.base_prompt_template + and local_address + ): + # 获取天气信息(使用全局缓存) + self._get_weather_info(conn, local_address) # 获取配置的上下文数据 if hasattr(conn, "device_id") and conn.device_id: