[Feature] 让模型参与分段:新增 segmented_reply.model_controlled,用标记/换行决定气泡边界

Abierto
#11,132 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
12/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

Línea de trabajo

Start with ResultDecorateStage in astrbot/core/result_decorate/stage.py (the early return on streaming results and the words_count_threshold skip near line 220), then RespondStage in astrbot/core/respond/stage.py where _calc_comp_interval and the per-segment asyncio.sleep(i) live. The config schema is in astrbot/core/config/default.py. This touches prompt injection and streaming, so it needs maintainer design agreement first. Done would mean the model-controlled markers and the streaming fallback are honored, with the old regex/words behavior unchanged when the option is off.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

现象

分段边界由程序决定,模型无法参与:

  1. 只有程序切分:split_mode 只有 regex / words(astrbot/core/config/default.py:111-129),切分发生在 result_decorate/stage.py:208-267,输入是最终纯文本。模型没有「这句单独发」「这两句连在一起」的表达方式;换行、空行、语义停顿都不影响切分,结果类型中也没有「分段意图」字段。
  2. 流式下配置也不生效:streaming_response=true 时 ResultDecorateStage 对流式结果直接 return(stage.py:134-135、:137/191-193),实际按适配器硬编码的标点 。?!~… 和固定 sleep(1.5) 切分(platform/astr_message_event.py:342-353、sources/aiocqhttp/aiocqhttp_message_event.py:244-261),regex/interval 无人读取。
  3. 长文本不分段:超过 words_count_threshold(默认 150)的 Plain 整段跳过(stage.py:220)。
  4. 首段也要等待:respond/stage.py:355-356 每段发送前 asyncio.sleep(i),首段同样等待一个 interval(#9931 曾提出跳过,但未合并)。

期望行为

  1. 模型可控(可选,默认关闭):新增 segmented_reply.model_controlled,向 system prompt 注入约定「需要换气泡时用空行或 <|seg|> 分隔」;切分时优先按标记,模型未给标记则回退现有 regex/words,老用户行为不变。
  2. 流式复用配置(可选;若维护者认为 #8313 已覆盖,可只做第 1 点):send_streaming 的 fallback 接收 split_mode / regex / split_words / interval,不再硬编码标点和 1.5s。
  3. 长文本语义:words_count_threshold 改为「超过则按更粗粒度再切」,而不是跳过切分。
  4. 首段延迟可配:增加「首段前是否 sleep」的开关(可复用 #9931 的思路)。

与已有 issue 的关系

  • #8313(open)只要求流式 fallback 的分割字符可自定义;本 issue 的核心是模型参与分段,第 2 点只是附带。
  • #10176(open PR)方向相反,要求工具调用后的最终答案不要乱切。
  • #10722(open)是发送侧管控(刷屏、在途分段不可打断),与「边界由谁决定」不同层。
  • #10916(open PR)是最大分段数;#9931(closed 未合并)是跳过首段延迟。
  • 本 issue 不是以上任一条的重复。

复现(模型无法控制边界)

  1. 开启 segmented_reply(split_mode=regex,默认正则)。
  2. 要求模型「刚才那句单独发」「这三句连成一条发」,实际仍按 。?!~… 切,模型意图不生效。
  3. 让模型用空行或换行表达换气泡,结果被忽略或并入同一段。
  4. 打开 streaming_response=true 再试:连 regex/interval 也不生效,变成硬编码标点加固定 1.5s。

版本 / 环境

  • AstrBot v4.29.4(6133541,2026-10-31);master 630d5cee(2026-11-14)核心分段逻辑未变
  • Linux + aiocqhttp/NapCat,Python 3.12
  • streaming_response=true,segmented_reply.enable=true

建议实现

  • ResultDecorateStage:不要对流式结果一刀切 return;把分段参数传给 send_streaming,由 fallback 使用配置切句(同时消化 #8313)。
  • RespondStage:流式分支复用 _calc_comp_interval 的节奏控制,而不是在适配器内部写死 1.5s。
  • system prompt:按 model_controlled 开关注入分隔协议;切分函数优先按标记,其次 regex;兼容 only_llm_result。
Lenguaje dominante
Python
Estrellas
46.9k
Forks
3.6k
Merge medio
1 d 5 h
PR fusionados (30 d)
140

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AstrBotDevs/AstrBot

Todos los issues de AstrBotDevs/AstrBot

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.