feat:合并normal和focus的prompt构建
This commit is contained in:
@@ -10,6 +10,7 @@ from typing import List, Dict
|
||||
import difflib
|
||||
import json
|
||||
from json_repair import repair_json
|
||||
from src.person_info.person_info import get_person_info_manager
|
||||
|
||||
|
||||
logger = get_logger("memory_activator")
|
||||
@@ -75,8 +76,8 @@ class MemoryActivator:
|
||||
)
|
||||
self.running_memory = []
|
||||
self.cached_keywords = set() # 用于缓存历史关键词
|
||||
|
||||
async def activate_memory(self, observations) -> List[Dict]:
|
||||
|
||||
async def activate_memory_with_chat_history(self, chat_id, target_message, chat_history_prompt) -> List[Dict]:
|
||||
"""
|
||||
激活记忆
|
||||
|
||||
@@ -90,14 +91,14 @@ class MemoryActivator:
|
||||
if not global_config.memory.enable_memory:
|
||||
return []
|
||||
|
||||
obs_info_text = ""
|
||||
for observation in observations:
|
||||
if isinstance(observation, ChattingObservation):
|
||||
obs_info_text += observation.talking_message_str_truncate_short
|
||||
elif isinstance(observation, StructureObservation):
|
||||
working_info = observation.get_observe_info()
|
||||
for working_info_item in working_info:
|
||||
obs_info_text += f"{working_info_item['type']}: {working_info_item['content']}\n"
|
||||
# obs_info_text = ""
|
||||
# for observation in observations:
|
||||
# if isinstance(observation, ChattingObservation):
|
||||
# obs_info_text += observation.talking_message_str_truncate_short
|
||||
# elif isinstance(observation, StructureObservation):
|
||||
# working_info = observation.get_observe_info()
|
||||
# for working_info_item in working_info:
|
||||
# obs_info_text += f"{working_info_item['type']}: {working_info_item['content']}\n"
|
||||
|
||||
# logger.info(f"回忆待检索内容:obs_info_text: {obs_info_text}")
|
||||
|
||||
@@ -106,7 +107,7 @@ class MemoryActivator:
|
||||
|
||||
prompt = await global_prompt_manager.format_prompt(
|
||||
"memory_activator_prompt",
|
||||
obs_info_text=obs_info_text,
|
||||
obs_info_text=chat_history_prompt,
|
||||
cached_keywords=cached_keywords_str,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user