Skip to content

feat: 支持按消息条数批量判断群聊回复 - #30

Open
mocha114514 wants to merge 2 commits into
advent259141:masterfrom
mocha114514:feat/batch-judgment
Open

mocha114514 wants to merge 2 commits into
advent259141:masterfrom
mocha114514:feat/batch-judgment

Conversation

@mocha114514

Copy link
Copy Markdown

背景

目前每条符合条件的群聊消息都会触发一次判断。群聊消息较多时,判断模型的调用频率较高。

本次新增可选的批量判断机制:累计一定数量的新消息后,结合整批内容统一判断是否适合参与群聊,而不是只判断最后一条消息。

主要改动

  • 新增 judge_message_interval 配置,范围 1–100,默认 1,保持原有逐条判断行为。
  • 每个群独立累计消息,凑满指定条数后触发一轮判断,支持 LLM 和 JEV 两种后端。
  • 完整保留本批消息,不受额外历史条数限制,也不会在历史中重复传入。
  • 图片判断开启时,本批图片随对应消息参与判断;JEV 图片去重、数量限制处理后,仍保持图片与消息的正确对应。
  • /heartflow 增加待判断消息的累计进度,并补充配置说明及测试。

例如:

{
  "judge_message_interval": 10,
  "judge_context_count": 5
}

表示每累计 10 条符合条件的新消息,携带这整批消息和最多 5 条额外历史,统一判断一次。

行为与兼容性

  • 未凑满批次时继续等待,不增加定时或超时补判。
  • 命令、机器人自身消息、直接唤醒消息、冷却期消息及白名单外消息不计入批次。
  • 直接 @/唤醒仍按 AstrBot 原有流程即时处理,实际回复流程不变。
  • 判定通过、不通过、失败或取消后,本批均结束,下一批重新累计;原有 LLM 格式重试和判断超时规则保留。
  • 重置、群状态淘汰、插件重载或重启会清空相应待判断批次。
  • 保留现有图片开关及 JEV 图片数量上限,不额外逐张调用模型生成图片描述。
  • 不新增项目依赖。

验证

  • 56 项单元测试通过,其中新增 11 项。
  • 覆盖批次计数、群隔离、消息过滤、并发、完整图文输入、图片归属、重试及状态清理。
  • 修改的 Python 文件通过 Ruff 静态检查和格式检查。
  • 配置 JSON 校验及 git diff --check 通过。
  • HTTP 测试使用本地模拟服务,未调用真实模型。

Accumulate eligible messages per chat before one combined LLM or JEV judgment. Keep the default interval at one for existing behavior.

Preserve complete batch text and image ownership independently of history limits, including JEV image deduplication and caps. Clear batches after judgment, failure, cancellation, reset, or eviction.

Document the setting and add focused batching and image-mapping tests. Validation: 56 unit tests passed, plus Ruff and configuration JSON checks.
Remove the expanded batching section and related prose changes. Keep only the new judgment interval entry and the clarification of additional history in the configuration table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant