feat: 更新消息管理和数据库操作日志,增强调试信息
This commit is contained in:
@@ -162,17 +162,17 @@ class StreamContext(BaseDataModel):
|
||||
"stream_id": self.stream_id,
|
||||
}
|
||||
await unified_manager.add_message(message_dict)
|
||||
logger.debug(f"<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ: {message.message_id}")
|
||||
logger.debug(f"消息已添加到统一记忆系统: {message.message_id}")
|
||||
except Exception as e:
|
||||
logger.error(f"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳʧ<EFBFBD><EFBFBD>: {e}")
|
||||
logger.error(f"添加消息到统一记忆系统失败: {e}")
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> {self.stream_id}: {e}")
|
||||
logger.error(f"添加消息到上下文失败 {self.stream_id}: {e}")
|
||||
return False
|
||||
|
||||
async def update_message(self, message_id: str, updates: dict[str, Any]) -> bool:
|
||||
"""<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>Ϣ"""
|
||||
"""更新上下文中的消息信息"""
|
||||
try:
|
||||
for message in self.unread_messages:
|
||||
if str(message.message_id) == str(message_id):
|
||||
@@ -194,10 +194,10 @@ class StreamContext(BaseDataModel):
|
||||
message.should_reply = updates["should_reply"]
|
||||
break
|
||||
|
||||
logger.debug(f"<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ: {self.stream_id}/{message_id}")
|
||||
logger.debug(f"更新消息信息: {self.stream_id}/{message_id}")
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<EFBFBD><EFBFBD> {self.stream_id}/{message_id}: {e}")
|
||||
logger.error(f"更新消息信息失败 {self.stream_id}/{message_id}: {e}")
|
||||
return False
|
||||
|
||||
def add_action_to_message(self, message_id: str, action: str):
|
||||
|
||||
@@ -149,7 +149,6 @@ class CRUDBase:
|
||||
cache = await get_cache()
|
||||
cached_dict = await cache.get(cache_key)
|
||||
if cached_dict is not None:
|
||||
logger.debug(f"缓存命中: {cache_key}")
|
||||
# 从字典恢复对象
|
||||
return _dict_to_model(self.model, cached_dict)
|
||||
|
||||
@@ -194,7 +193,6 @@ class CRUDBase:
|
||||
cache = await get_cache()
|
||||
cached_dict = await cache.get(cache_key)
|
||||
if cached_dict is not None:
|
||||
logger.debug(f"缓存命中: {cache_key}")
|
||||
# 从字典恢复对象
|
||||
return _dict_to_model(self.model, cached_dict)
|
||||
|
||||
@@ -247,7 +245,6 @@ class CRUDBase:
|
||||
cache = await get_cache()
|
||||
cached_dicts = await cache.get(cache_key)
|
||||
if cached_dicts is not None:
|
||||
logger.debug(f"缓存命中: {cache_key}")
|
||||
# 从字典列表恢复对象列表
|
||||
return [_dict_to_model(self.model, d) for d in cached_dicts]
|
||||
|
||||
|
||||
@@ -199,7 +199,6 @@ class QueryBuilder(Generic[T]):
|
||||
cache = await get_cache()
|
||||
cached_dicts = await cache.get(cache_key)
|
||||
if cached_dicts is not None:
|
||||
logger.debug(f"缓存命中: {cache_key}")
|
||||
dict_rows = [dict(row) for row in cached_dicts]
|
||||
if as_dict:
|
||||
return dict_rows
|
||||
@@ -238,7 +237,6 @@ class QueryBuilder(Generic[T]):
|
||||
cache = await get_cache()
|
||||
cached_dict = await cache.get(cache_key)
|
||||
if cached_dict is not None:
|
||||
logger.debug(f"缓存命中: {cache_key}")
|
||||
row = dict(cached_dict)
|
||||
if as_dict:
|
||||
return row
|
||||
@@ -277,7 +275,6 @@ class QueryBuilder(Generic[T]):
|
||||
cache = await get_cache()
|
||||
cached = await cache.get(cache_key)
|
||||
if cached is not None:
|
||||
logger.debug(f"缓存命中: {cache_key}")
|
||||
return cached
|
||||
|
||||
# 构建count查询
|
||||
|
||||
@@ -192,7 +192,6 @@ def cached(
|
||||
cached_result = await cache.get(cache_key)
|
||||
|
||||
if cached_result is not None:
|
||||
logger.debug(f"缓存命中: {cache_key}")
|
||||
return cached_result
|
||||
|
||||
# 执行函数
|
||||
|
||||
@@ -663,6 +663,18 @@ class ChatterPlanFilter:
|
||||
f"[{action}] 找不到目标消息,target_message_id: {action_data.get('target_message_id')}"
|
||||
)
|
||||
|
||||
# reply 动作必须有目标消息,如果仍然为 None,则使用最新消息
|
||||
if action in ["reply", "proactive_reply"] and action_message_obj is None:
|
||||
logger.warning(f"[{action}] 目标消息为空,强制使用最新消息作为兜底")
|
||||
latest_message_dict = self._get_latest_message(message_id_list)
|
||||
if latest_message_dict:
|
||||
from src.common.data_models.database_data_model import DatabaseMessages
|
||||
try:
|
||||
action_message_obj = DatabaseMessages(**latest_message_dict)
|
||||
logger.info(f"[{action}] 成功使用最新消息: {action_message_obj.message_id}")
|
||||
except Exception as e:
|
||||
logger.error(f"[{action}] 无法转换最新消息: {e}")
|
||||
|
||||
return ActionPlannerInfo(
|
||||
action_type=action,
|
||||
reasoning=reasoning,
|
||||
|
||||
Reference in New Issue
Block a user