From 96f50d929b51820ebe7a60d43dd89d866ff0d711 Mon Sep 17 00:00:00 2001 From: liuwei Date: Wed, 15 Apr 2026 10:52:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=94=AE=E8=B0=83=E6=95=B4=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit social_short 从“1句 + 1条”改成“最多2句 + 最多2条”,允许续发,避免戛然而止。 qa_fast / qa_with_context 也改为允许分条续发,避免中间硬断。 smart_clip 的弱标点回看窗口从 4 提高到 12,更容易切在自然停顿处(逗号/顿号等)。 同步更新了长度规则文案:明确“必要时可拆两条,保证语义完整”。 你给的这句原文在新逻辑下会优先拆成两条,而不是第一条被截到“我听着怎么这”这种半句。 --- plugins/ai_auto_response/core/reply_formatter.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/ai_auto_response/core/reply_formatter.py b/plugins/ai_auto_response/core/reply_formatter.py index 616e250..4330f3f 100644 --- a/plugins/ai_auto_response/core/reply_formatter.py +++ b/plugins/ai_auto_response/core/reply_formatter.py @@ -12,11 +12,12 @@ def finalize_reply(response: str, reply_mode: str) -> List[str]: text = text.replace("\n", " ").strip() if reply_mode == "social_short": - return split_reply_chunks(text, sentence_limit=1, char_limit=48, chunk_limit=1, allow_clip_split=False) + # 社交短句允许拆成两条,避免长句被硬截断成半句。 + return split_reply_chunks(text, sentence_limit=2, char_limit=48, chunk_limit=2, allow_clip_split=True) if reply_mode == "qa_fast": - return split_reply_chunks(text, sentence_limit=2, char_limit=42, chunk_limit=2, allow_clip_split=False) + return split_reply_chunks(text, sentence_limit=2, char_limit=42, chunk_limit=2, allow_clip_split=True) if reply_mode == "qa_with_context": - return split_reply_chunks(text, sentence_limit=2, char_limit=54, chunk_limit=2, allow_clip_split=False) + return split_reply_chunks(text, sentence_limit=2, char_limit=54, chunk_limit=2, allow_clip_split=True) return [take_first_sentence(text, 28).strip()] @@ -29,7 +30,7 @@ def preview_text(text: str, limit: int = 80) -> str: def build_length_rule(reply_mode: str) -> str: if reply_mode == "social_short": - return "默认只回1句短话,尽量简短,但必须表达完整;通常控制在8到24个字,必要时可以放宽到一整句短句,别截半句。" + return "默认优先1句短话;必要时可以拆成2条短消息,保证语义完整,不要截半句。" if reply_mode == "qa_fast": return "优先1句话;如果确实需要,可以拆成2条短消息发出,每条尽量控制在42字内,先给结论,不要主动补第二层解释。" if reply_mode == "qa_with_context": @@ -90,7 +91,7 @@ def smart_clip(text: str, limit: int) -> str: weak_punctuation = ",,、;;::" split_at = _find_split_at(window, strong_punctuation) if split_at < 0: - split_at = _find_split_at(window, weak_punctuation, lookback=4) + split_at = _find_split_at(window, weak_punctuation, lookback=12) if split_at >= 0: return window[:split_at].rstrip(",,、;;::。!?!? ").strip() return window.rstrip(",,、;;:: ").strip()