v0.3.3 异步处理记忆,修复了GUI
This commit is contained in:
@@ -90,7 +90,7 @@ async def monitor_relationships():
|
||||
async def build_memory_task():
|
||||
"""每30秒执行一次记忆构建"""
|
||||
print("\033[1;32m[记忆构建]\033[0m 开始构建记忆...")
|
||||
hippocampus.build_memory(chat_size=12)
|
||||
await hippocampus.build_memory(chat_size=30)
|
||||
print("\033[1;32m[记忆构建]\033[0m 记忆构建完成")
|
||||
|
||||
|
||||
|
||||
@@ -136,3 +136,4 @@ llm_config.DEEP_SEEK_BASE_URL = config.deep_seek_base_url
|
||||
if not global_config.enable_advance_output:
|
||||
# logger.remove()
|
||||
pass
|
||||
|
||||
|
||||
@@ -72,12 +72,15 @@ class PromptBuilder:
|
||||
# print(f"\033[1;32m[前额叶]\033[0m 合并所有需要的记忆2: {list(overlapping_second_layer)}")
|
||||
|
||||
# 使用集合去重
|
||||
all_memories = list(set(all_first_layer_items) | set(overlapping_second_layer))
|
||||
# 从每个来源随机选择2条记忆(如果有的话)
|
||||
selected_first_layer = random.sample(all_first_layer_items, min(2, len(all_first_layer_items))) if all_first_layer_items else []
|
||||
selected_second_layer = random.sample(list(overlapping_second_layer), min(2, len(overlapping_second_layer))) if overlapping_second_layer else []
|
||||
|
||||
# 合并并去重
|
||||
all_memories = list(set(selected_first_layer + selected_second_layer))
|
||||
if all_memories:
|
||||
print(f"\033[1;32m[前额叶]\033[0m 合并所有需要的记忆: {all_memories}")
|
||||
|
||||
if all_memories: # 只在列表非空时选择随机项
|
||||
random_item = choice(all_memories)
|
||||
random_item = " ".join(all_memories)
|
||||
memory_prompt = f"看到这些聊天,你想起来{random_item}\n"
|
||||
else:
|
||||
memory_prompt = "" # 如果没有记忆,则返回空字符串
|
||||
|
||||
Reference in New Issue
Block a user