feat(context): 增加跨上下文黑名单模式

为跨上下文共享功能引入了黑名单模式,并增加了相应的配置选项。

- 在 `ContextGroup` 配置中增加了 `mode` 字段,支持 "whitelist"(白名单)和 "blacklist"(黑名单)模式。
- 增加了 `default_limit` 配置项,用于黑名单模式下的默认消息获取数量。
- 重构了 `cross_context_api` 以支持新的黑名单逻辑,现在可以共享除了黑名单中指定聊天外的所有聊天上下文。
- 更新了配置文件模板以包含新模式的说明和示例。
This commit is contained in:
minecraft1024a
2025-10-11 19:45:32 +08:00
parent 989956ed57
commit f7ed5211a3
4 changed files with 106 additions and 28 deletions

View File

@@ -1060,12 +1060,7 @@ class Prompt:
chat_stream.group_info.group_id if chat_stream.group_info else chat_stream.user_info.user_id
)
current_type = "group" if chat_stream.group_info else "private"
other_chat_infos = [
chat_info
for chat_info in context_group.chat_ids
if chat_info[:2] != [current_type, str(current_chat_raw_id)]
]
return await cross_context_api.build_cross_context_normal(chat_stream, other_chat_infos)
return await cross_context_api.build_cross_context_normal(chat_stream, context_group)
elif prompt_mode == "s4u":
return await cross_context_api.build_cross_context_s4u(chat_stream, context_group, target_user_info)