fix:修复了记忆快速提取问题
This commit is contained in:
@@ -425,7 +425,10 @@ class HeartFChatting:
|
||||
self.all_observations = observations
|
||||
|
||||
with Timer("回忆", cycle_timers):
|
||||
logger.debug(f"{self.log_prefix} 开始回忆")
|
||||
running_memorys = await self.memory_activator.activate_memory(observations)
|
||||
logger.debug(f"{self.log_prefix} 回忆完成")
|
||||
print(running_memorys)
|
||||
|
||||
with Timer("执行 信息处理器", cycle_timers):
|
||||
all_plan_info = await self._process_processors(observations, running_memorys, cycle_timers)
|
||||
|
||||
@@ -61,6 +61,9 @@ class MemoryActivator:
|
||||
elif isinstance(observation, HFCloopObservation):
|
||||
obs_info_text += observation.get_observe_info()
|
||||
|
||||
|
||||
logger.debug(f"回忆待检索内容:obs_info_text: {obs_info_text}")
|
||||
|
||||
# prompt = await global_prompt_manager.format_prompt(
|
||||
# "memory_activator_prompt",
|
||||
# obs_info_text=obs_info_text,
|
||||
@@ -81,7 +84,7 @@ class MemoryActivator:
|
||||
# valid_keywords=keywords, max_memory_num=3, max_memory_length=2, max_depth=3
|
||||
# )
|
||||
related_memory = await HippocampusManager.get_instance().get_memory_from_text(
|
||||
text=obs_info_text, max_memory_num=3, max_memory_length=2, max_depth=3, fast_retrieval=True
|
||||
text=obs_info_text, max_memory_num=5, max_memory_length=2, max_depth=3, fast_retrieval=True
|
||||
)
|
||||
|
||||
# logger.debug(f"获取到的记忆: {related_memory}")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import traceback
|
||||
from typing import Tuple, Dict, List, Any, Optional
|
||||
from src.chat.focus_chat.planners.actions.base_action import BaseAction
|
||||
from src.chat.focus_chat.planners.actions.base_action import BaseAction,register_action #noqa F401
|
||||
from src.chat.heart_flow.observation.chatting_observation import ChattingObservation
|
||||
from src.chat.focus_chat.hfc_utils import create_empty_anchor_message
|
||||
from src.common.logger_manager import get_logger
|
||||
|
||||
@@ -338,7 +338,8 @@ class Hippocampus:
|
||||
# 去重
|
||||
keywords = list(set(keywords))
|
||||
# 限制关键词数量
|
||||
keywords = keywords[:5]
|
||||
logger.debug(f"提取关键词: {keywords}")
|
||||
|
||||
else:
|
||||
# 使用LLM提取关键词
|
||||
topic_num = min(5, max(1, int(len(text) * 0.1))) # 根据文本长度动态调整关键词数量
|
||||
@@ -361,7 +362,7 @@ class Hippocampus:
|
||||
# 过滤掉不存在于记忆图中的关键词
|
||||
valid_keywords = [keyword for keyword in keywords if keyword in self.memory_graph.G]
|
||||
if not valid_keywords:
|
||||
# logger.info("没有找到有效的关键词节点")
|
||||
logger.info("没有找到有效的关键词节点")
|
||||
return []
|
||||
|
||||
logger.debug(f"有效的关键词: {', '.join(valid_keywords)}")
|
||||
|
||||
Reference in New Issue
Block a user