feat(context): 增强s4u跨上下文模式并重构API

在跨上下文功能中为s4u模式引入`s4u_ignore_whitelist`配置项。当启用时,除了白名单中配置的聊天记录外,还会自动获取目标用户与Bot的私聊记录,以构建更全面的用户画像。

主要变更:
- 在 `ContextGroup` 配置中添加 `s4u_ignore_whitelist` 字段。
- 重构 `cross_context_api`,将 `get_context_groups` 更改为 `get_context_group`,使其返回完整的 `ContextGroup` 对象而非仅ID列表,以便于访问新配置。
- 调整 `build_cross_context_s4u` 函数以处理新逻辑,包括获取私聊记录和避免重复处理。
- 更新了配置文件模板以包含新选项的说明和示例。
This commit is contained in:
minecraft1024a
2025-10-11 19:19:52 +08:00
committed by Windpicker-owo
parent 7481962b64
commit 07d60d3604
4 changed files with 95 additions and 44 deletions

View File

@@ -633,6 +633,9 @@ class ContextGroup(ValidatedConfigBase):
"""上下文共享组配置"""
name: str = Field(..., description="共享组的名称")
s4u_ignore_whitelist: bool = Field(
default=False, description="在s4u模式下, 是否无视白名单, 获取用户所有私聊消息"
)
chat_ids: list[list[str]] = Field(
...,
description='属于该组的聊天ID列表格式为 [["type", "chat_id"], ...],例如 [["group", "123456"], ["private", "789012"]]',