Merge branch 'main' into Knowledge-Base

This commit is contained in:
hrz
2025-11-08 16:07:21 +08:00
2 changed files with 14 additions and 9 deletions
+2 -2
View File
@@ -798,9 +798,9 @@ class ConnectionHandler:
if tools_call is not None and len(tools_call) > 0:
tool_call_flag = True
if tools_call[0].id is not None:
if tools_call[0].id is not None and tools_call[0].id != "":
function_id = tools_call[0].id
if tools_call[0].function.name is not None:
if tools_call[0].function.name is not None and tools_call[0].function.name != "":
function_name = tools_call[0].function.name
if tools_call[0].function.arguments is not None:
function_arguments += tools_call[0].function.arguments
@@ -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(