[Feature] 让模型参与分段:新增 segmented_reply.model_controlled,用标记/换行决定气泡边界
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 12/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
现象
分段边界由程序决定,模型无法参与:
- 只有程序切分:
split_mode只有regex/words(astrbot/core/config/default.py:111-129),切分发生在result_decorate/stage.py:208-267,输入是最终纯文本。模型没有「这句单独发」「这两句连在一起」的表达方式;换行、空行、语义停顿都不影响切分,结果类型中也没有「分段意图」字段。 - 流式下配置也不生效:
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无人读取。 - 长文本不分段:超过
words_count_threshold(默认 150)的Plain整段跳过(stage.py:220)。 - 首段也要等待:
respond/stage.py:355-356每段发送前asyncio.sleep(i),首段同样等待一个 interval(#9931 曾提出跳过,但未合并)。
期望行为
- 模型可控(可选,默认关闭):新增
segmented_reply.model_controlled,向 system prompt 注入约定「需要换气泡时用空行或<|seg|>分隔」;切分时优先按标记,模型未给标记则回退现有 regex/words,老用户行为不变。 - 流式复用配置(可选;若维护者认为 #8313 已覆盖,可只做第 1 点):
send_streaming的 fallback 接收split_mode/regex/split_words/interval,不再硬编码标点和 1.5s。 - 长文本语义:
words_count_threshold改为「超过则按更粗粒度再切」,而不是跳过切分。 - 首段延迟可配:增加「首段前是否 sleep」的开关(可复用 #9931 的思路)。
与已有 issue 的关系
- #8313(open)只要求流式 fallback 的分割字符可自定义;本 issue 的核心是模型参与分段,第 2 点只是附带。
- #10176(open PR)方向相反,要求工具调用后的最终答案不要乱切。
- #10722(open)是发送侧管控(刷屏、在途分段不可打断),与「边界由谁决定」不同层。
- #10916(open PR)是最大分段数;#9931(closed 未合并)是跳过首段延迟。
- 本 issue 不是以上任一条的重复。
复现(模型无法控制边界)
- 开启
segmented_reply(split_mode=regex,默认正则)。 - 要求模型「刚才那句单独发」「这三句连成一条发」,实际仍按
。?!~…切,模型意图不生效。 - 让模型用空行或换行表达换气泡,结果被忽略或并入同一段。
- 打开
streaming_response=true再试:连regex/interval也不生效,变成硬编码标点加固定 1.5s。
版本 / 环境
- AstrBot v4.29.4(
6133541,2026-10-31);master630d5cee(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。
- Lingua principale
- Python
- Stelle
- 46.9k
- Fork
- 3.6k
- Merge medio
- 1g 5h
- PR unite (30g)
- 140
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AstrBotDevs/AstrBot
-
[Bug] Sending a Telegram message chain twice duplicates mentionsForse già presa @123XieC l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AstrBotDevs/AstrBot#11125 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Telegram album debounce exceeds the maximum waitForse già presa @123XieC l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AstrBotDevs/AstrBot#11123 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
AstrBotDevs/AstrBot#11034 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] OpenAI-compatible Gemini 工具 schema const 导致 400Forse già presa @arccat-114 l’ha presa 27 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
AstrBotDevs/AstrBot#10720 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Discord slash command sync aborts with KeyError when a plugin handler is defined in a submoduleForse già presa @yuexia5 l’ha presa 32 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
AstrBotDevs/AstrBot#10626 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di AstrBotDevs/AstrBot
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
abetlen/llama-cpp-python#2424 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug IronPython Python 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pyrevitlabs/pyRevit#4184 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
jqueryscript/awesome-claude-code#1009 ·
-
tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno