Update s4u_prompt.py

pull/1222/head
CNMr.Sunshine 2025-08-30 17:33:01 +08:00 committed by GitHub
parent ce8a390f8a
commit c633162dcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 11 deletions

View File

@ -158,18 +158,23 @@ class PromptBuilder:
return relation_prompt return relation_prompt
async def build_memory_block(self, text: str) -> str: async def build_memory_block(self, text: str) -> str:
# 待更新记忆系统 # 如果记忆系统被禁用,直接返回空字符串
return "" if not global_config.memory.enable_memory:
return ""
related_memory = await hippocampus_manager.get_memory_from_text( try:
text=text, max_memory_num=2, max_memory_length=2, max_depth=3, fast_retrieval=False related_memory = await hippocampus_manager.get_memory_from_text(
) text=text, max_memory_num=2, max_memory_length=2, max_depth=3, fast_retrieval=False
)
related_memory_info = ""
if related_memory:
for memory in related_memory:
related_memory_info += memory[1]
return await global_prompt_manager.format_prompt("memory_prompt", memory_info=related_memory_info)
except Exception as e:
logger.warning(f"获取记忆失败,跳过记忆功能: {e}")
related_memory_info = ""
if related_memory:
for memory in related_memory:
related_memory_info += memory[1]
return await global_prompt_manager.format_prompt("memory_prompt", memory_info=related_memory_info)
return "" return ""
def build_chat_history_prompts(self, chat_stream: ChatStream, message: MessageRecvS4U): def build_chat_history_prompts(self, chat_stream: ChatStream, message: MessageRecvS4U):