refactor(memory): 移除混合记忆模型,全面转向向量化瞬时记忆
删除了 `HybridInstantMemory` 模块及其复杂的策略判断、同步和检索逻辑。此举旨在简化记忆系统的架构,统一采用 `VectorInstantMemoryV2` 作为唯一的瞬时记忆解决方案。(虽然我也不知道效果好不好反正先转了再说,因为基于大模型的瞬时记忆有那么一点点慢)
This commit is contained in:
@@ -25,7 +25,7 @@ from src.chat.utils.chat_message_builder import (
|
||||
)
|
||||
from src.chat.express.expression_selector import expression_selector
|
||||
from src.chat.memory_system.memory_activator import MemoryActivator
|
||||
from src.chat.memory_system.hybrid_instant_memory import HybridInstantMemory
|
||||
from src.chat.memory_system.vector_instant_memory import VectorInstantMemoryV2
|
||||
from src.mood.mood_manager import mood_manager
|
||||
from src.person_info.relationship_fetcher import relationship_fetcher_manager
|
||||
from src.person_info.person_info import get_person_info_manager
|
||||
@@ -226,8 +226,8 @@ class DefaultReplyer:
|
||||
|
||||
self.heart_fc_sender = HeartFCSender()
|
||||
self.memory_activator = MemoryActivator()
|
||||
# 使用混合瞬时记忆系统V2,支持自定义保留时间
|
||||
self.instant_memory = HybridInstantMemory(
|
||||
# 使用纯向量瞬时记忆系统V2,支持自定义保留时间
|
||||
self.instant_memory = VectorInstantMemoryV2(
|
||||
chat_id=self.chat_stream.stream_id,
|
||||
retention_hours=1
|
||||
)
|
||||
@@ -474,20 +474,13 @@ class DefaultReplyer:
|
||||
)
|
||||
|
||||
if global_config.memory.enable_instant_memory:
|
||||
# 异步存储聊天历史到混合记忆系统
|
||||
asyncio.create_task(self.instant_memory.create_and_store_memory(chat_history))
|
||||
# 异步存储聊天历史到向量记忆系统
|
||||
asyncio.create_task(self.instant_memory.store_message(chat_history))
|
||||
|
||||
# 从混合记忆系统获取相关记忆
|
||||
instant_memory_result = await self.instant_memory.get_memory(target)
|
||||
# 从向量记忆系统获取相关记忆上下文
|
||||
instant_memory = await self.instant_memory.get_memory_for_context(target)
|
||||
|
||||
# 处理不同类型的返回结果
|
||||
instant_memory = None
|
||||
if isinstance(instant_memory_result, list) and instant_memory_result:
|
||||
instant_memory = instant_memory_result[0]
|
||||
elif isinstance(instant_memory_result, str) and instant_memory_result:
|
||||
instant_memory = instant_memory_result
|
||||
|
||||
logger.info(f"混合瞬时记忆:{instant_memory}")
|
||||
logger.info(f"向量瞬时记忆:{instant_memory}")
|
||||
|
||||
# 构建记忆字符串,即使某种记忆为空也要继续
|
||||
memory_str = ""
|
||||
|
||||
Reference in New Issue
Block a user