refactor(memory): 重构瞬时记忆为全量向量化存储模型

新系统采用“全量存储,定时清理”的设计理念,将所有聊天消息向量化并存入ChromaDB。通过后台线程定时清理过期消息,取代了之前基于“重要性模式”判断是否记忆的复杂逻辑。

主要变更:
- **全量存储**: 不再进行前置判断,所有消息均被向量化存储,简化了记忆创建流程。
- **定时清理**: 引入基于`threading`的后台任务,根据设定的`retention_hours`自动清理过期记忆,确保系统轻量高效。
- **简化检索**: 检索逻辑更新为直接查询相似消息,并增加了相似度阈值过滤和时间差格式化,提高了上下文的准确性和可读性。

在 `DefaultReplyer` 中,已切换至新的 `HybridInstantMemory`(其底层实现为V2),并优化了记忆上下文的构建逻辑,使其能更稳定地处理不同类型的记忆返回结果。
This commit is contained in:
minecraft1024a
2025-08-19 19:56:56 +08:00
committed by Windpicker-owo
parent 1b81694373
commit f2e82cf82f
7 changed files with 929 additions and 266 deletions

View File

@@ -118,4 +118,4 @@ class CookieService:
return cookies
logger.error("所有Cookie获取方法均失败。")
return None
return None

View File

@@ -312,11 +312,13 @@ class QZoneService:
raise RuntimeError(f"无法连接到Napcat服务: 超过最大重试次数({max_retries})")
async def _get_api_client(self, qq_account: str, stream_id: Optional[str]) -> Optional[Dict]:
cookies = await self._renew_and_load_cookies(qq_account, stream_id)
if not cookies: return None
cookies = await self.cookie_service.get_cookies(qq_account, stream_id)
if not cookies:
return None
p_skey = cookies.get('p_skey') or cookies.get('p_skey'.upper())
if not p_skey: return None
if not p_skey:
return None
gtk = self._generate_gtk(p_skey)
uin = cookies.get('uin', '').lstrip('o')