mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 09:03:54 +08:00
Merge pull request #2486 from xinnan-tech/hot-fix
fix:旧版本智控台配置文件,没有包含"prompt_template"配置会导致self.config.get("prompt_temp…
This commit is contained in:
@@ -66,7 +66,9 @@ class PromptManager:
|
|||||||
def _load_base_template(self):
|
def _load_base_template(self):
|
||||||
"""加载基础提示词模板"""
|
"""加载基础提示词模板"""
|
||||||
try:
|
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}"
|
cache_key = f"prompt_template:{template_path}"
|
||||||
|
|
||||||
# 先从缓存获取
|
# 先从缓存获取
|
||||||
@@ -117,7 +119,11 @@ class PromptManager:
|
|||||||
|
|
||||||
def _get_current_time_info(self) -> tuple:
|
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_date = get_current_date()
|
||||||
today_weekday = get_current_weekday()
|
today_weekday = get_current_weekday()
|
||||||
@@ -192,9 +198,7 @@ class PromptManager:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# 获取最新的时间信息(不缓存)
|
# 获取最新的时间信息(不缓存)
|
||||||
today_date, today_weekday, lunar_date = (
|
today_date, today_weekday, lunar_date = self._get_current_time_info()
|
||||||
self._get_current_time_info()
|
|
||||||
)
|
|
||||||
|
|
||||||
# 获取缓存的上下文信息
|
# 获取缓存的上下文信息
|
||||||
local_address = ""
|
local_address = ""
|
||||||
@@ -226,7 +230,8 @@ class PromptManager:
|
|||||||
emojiList=EMOJI_List,
|
emojiList=EMOJI_List,
|
||||||
device_id=device_id,
|
device_id=device_id,
|
||||||
client_ip=client_ip,
|
client_ip=client_ip,
|
||||||
*args, **kwargs
|
*args,
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
device_cache_key = f"device_prompt:{device_id}"
|
device_cache_key = f"device_prompt:{device_id}"
|
||||||
self.cache_manager.set(
|
self.cache_manager.set(
|
||||||
|
|||||||
Reference in New Issue
Block a user