This commit is contained in:
Windpicker-owo
2025-11-01 19:35:05 +08:00
4 changed files with 32 additions and 31 deletions

View File

@@ -1468,18 +1468,15 @@ class DefaultReplyer:
if now < start_time:
now += timedelta(days=1)
if start_time <= now < end_time:
duration_minutes = (now - start_time).total_seconds() / 60
remaining_minutes = (end_time - now).total_seconds() / 60
schedule_block = (
duration_minutes = (now - start_time).total_seconds() / 60
remaining_minutes = (end_time - now).total_seconds() / 60
schedule_block = (
f"你当前正在进行“{activity}”,"
f"计划时间从{start_time.strftime('%H:%M')}{end_time.strftime('%H:%M')}"
f"这项活动已经开始了{duration_minutes:.0f}分钟,"
f"预计还有{remaining_minutes:.0f}分钟结束。"
"(此为你的当前状态,仅供参考。除非被直接询问,否则不要在对话中主动提及。)"
)
else:
schedule_block = f"你当前正在进行“{activity}”。(此为你的当前状态,仅供参考。除非被直接询问,否则不要在对话中主动提及。)"
except (ValueError, AttributeError):
schedule_block = f"你当前正在进行“{activity}”。(此为你的当前状态,仅供参考。除非被直接询问,否则不要在对话中主动提及。)"

View File

@@ -350,10 +350,10 @@ def _default_normal_response_parser(
api_response.tool_calls = []
for call in message_part.tool_calls:
try:
arguments = orjson.loads(repair_json(call.function.arguments))
arguments = orjson.loads(repair_json(call.function.arguments)) # type: ignore
if not isinstance(arguments, dict):
raise RespParseException(resp, "响应解析失败,工具调用参数无法解析为字典类型")
api_response.tool_calls.append(ToolCall(call.id, call.function.name, arguments))
api_response.tool_calls.append(ToolCall(call.id, call.function.name, arguments)) # type: ignore
except orjson.JSONDecodeError as e:
raise RespParseException(resp, "响应解析失败,无法解析工具调用参数") from e

View File

@@ -218,14 +218,6 @@ class MainSystem:
cleanup_tasks = []
# 停止数据库服务
try:
from src.common.database.core import close_engine as stop_database
cleanup_tasks.append(("数据库服务", stop_database()))
except Exception as e:
logger.error(f"准备停止数据库服务时出错: {e}")
# 停止消息批处理器
try:
from src.chat.message_receive.storage import get_message_storage_batcher, get_message_update_batcher
@@ -329,6 +321,18 @@ class MainSystem:
else:
logger.warning("没有需要清理的任务")
# 停止数据库服务 (在所有其他任务完成后最后停止)
try:
from src.common.database.core import close_engine as stop_database
logger.info("正在停止数据库服务...")
await asyncio.wait_for(stop_database(), timeout=15.0)
logger.info("🛑 数据库服务已停止")
except asyncio.TimeoutError:
logger.error("停止数据库服务超时")
except Exception as e:
logger.error(f"停止数据库服务时出错: {e}")
def _cleanup(self) -> None:
"""同步清理资源(向后兼容)"""
try: