fix(dingtalk): 推理正文边界支持「首行即正文」并补齐卡片结构诊断
- BodyStartOffset:内容首个非空行即结构行时正文从头开始,避免收尾裁剪 把标题+首段一起删掉(118 条生产样本中 31 条、最多 526 字) - 语料回归守卫:隐藏前缀不得含结构行、上限 600 字;单测补 suffix 断言 - 卡片诊断新增 body_ok/body_line/body_prefix_runes/banner_pos/first_heading_line (定位流式残留推理末句,只看结构不看文本)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package reasoningmode
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBodyStartOffsetRecognizesStructuralBodyLines(t *testing.T) {
|
||||
leadIn := "根据检索到的资料,关于 CR20V 各关节电机最大旋转扭矩的说明如下:"
|
||||
@@ -46,10 +49,22 @@ func TestBodyStartOffsetRecognizesStructuralBodyLines(t *testing.T) {
|
||||
ok: false,
|
||||
},
|
||||
{
|
||||
name: "body from the first line is left alone",
|
||||
name: "answer opens with its body: nothing is hidden",
|
||||
answer: heading + "\n\n各关节参数如下。",
|
||||
want: heading + "\n\n各关节参数如下。",
|
||||
ok: false,
|
||||
ok: true,
|
||||
},
|
||||
{
|
||||
name: "title and opening paragraph survive finalize",
|
||||
answer: "# 200万高职具身智能实训室搭配方案\n\n结合越疆现有的一体化实训平台,围绕具身智能教学场景,我们从教具、软件、课程三方面给出搭配建议。\n\n## 一、先明确三条搭配原则\n\n- 匹配课程大纲\n- 控制预算\n",
|
||||
want: "# 200万高职具身智能实训室搭配方案\n\n结合越疆现有的一体化实训平台,围绕具身智能教学场景,我们从教具、软件、课程三方面给出搭配建议。\n\n## 一、先明确三条搭配原则\n\n- 匹配课程大纲\n- 控制预算\n",
|
||||
ok: true,
|
||||
},
|
||||
{
|
||||
name: "leading blank lines before the title",
|
||||
answer: "\n\n# 标题\n\n正文。",
|
||||
want: "# 标题\n\n正文。",
|
||||
ok: true,
|
||||
},
|
||||
{
|
||||
name: "structural line inside a fence is ignored",
|
||||
@@ -74,6 +89,9 @@ func TestBodyStartOffsetRecognizesStructuralBodyLines(t *testing.T) {
|
||||
if body != tt.want {
|
||||
t.Fatalf("body = %q, want %q", body, tt.want)
|
||||
}
|
||||
if !strings.HasSuffix(tt.answer, body) {
|
||||
t.Fatalf("body %q is not a suffix of the answer: the rule ate content", body)
|
||||
}
|
||||
if trimmed := TrimReasoningNarration(tt.answer); trimmed != tt.want {
|
||||
t.Fatalf("TrimReasoningNarration = %q, want %q", trimmed, tt.want)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user