尝试减少不同群内的同义词混淆 以及允许用户设置指定群组记忆私有
用户设置指定群组记忆私有会导致记忆的语料严重减少 未设置群组记忆私有的记忆会开放对于所有群聊 因此要不就修改其他记忆配置 增强学习/记忆能力 或者增加单一群组的信息流数量 或者增加公开记忆的信息流数量 记忆检索时会按以下优先级返回记忆: 当前群组的记忆(如果群聊属于某个群组) 当前群聊的记忆(如果不属于任何群组) 公共记忆(无群组/群聊标识的记忆) 其他非私有群组的记忆 5. 跨群记忆连接 同一群组内的主题使用较强连接(相似度×10) 跨群组的相似主题使用较弱连接(相似度×5) 相同群组/群聊的相似主题会获得20%的相似度加成
This commit is contained in:
@@ -104,6 +104,12 @@ class BotConfig:
|
||||
memory_ban_words: list = field(
|
||||
default_factory=lambda: ["表情包", "图片", "回复", "聊天记录"]
|
||||
) # 添加新的配置项默认值
|
||||
|
||||
# 是否优先使用当前群组的记忆
|
||||
memory_group_priority: bool = True # 默认开启群组记忆优先
|
||||
|
||||
# 群组记忆私有化
|
||||
memory_private_groups: dict = field(default_factory=dict) # 群组私有记忆配置
|
||||
|
||||
@staticmethod
|
||||
def get_config_dir() -> str:
|
||||
@@ -304,6 +310,12 @@ class BotConfig:
|
||||
config.memory_forget_time = memory_config.get("memory_forget_time", config.memory_forget_time)
|
||||
config.memory_forget_percentage = memory_config.get("memory_forget_percentage", config.memory_forget_percentage)
|
||||
config.memory_compress_rate = memory_config.get("memory_compress_rate", config.memory_compress_rate)
|
||||
# 添加对memory_group_priority配置项的加载
|
||||
config.memory_group_priority = memory_config.get("memory_group_priority", config.memory_group_priority)
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.9"):
|
||||
# 添加群组记忆私有化配置项的加载
|
||||
config.memory_private_groups = memory_config.get("memory_private_groups", {})
|
||||
|
||||
def mood(parent: dict):
|
||||
mood_config = parent["mood"]
|
||||
|
||||
@@ -91,12 +91,20 @@ class PromptBuilder:
|
||||
memory_prompt = ''
|
||||
start_time = time.time()
|
||||
|
||||
# 获取群组ID
|
||||
group_id = None
|
||||
if stream_id:
|
||||
chat_stream = chat_manager.get_stream(stream_id)
|
||||
if chat_stream and chat_stream.group_info:
|
||||
group_id = chat_stream.group_info.group_id
|
||||
|
||||
# 调用 hippocampus 的 get_relevant_memories 方法
|
||||
relevant_memories = await hippocampus.get_relevant_memories(
|
||||
text=message_txt,
|
||||
max_topics=5,
|
||||
similarity_threshold=0.4,
|
||||
max_memory_num=5
|
||||
max_memory_num=5,
|
||||
group_id=group_id # 传递群组ID
|
||||
)
|
||||
|
||||
if relevant_memories:
|
||||
|
||||
Reference in New Issue
Block a user