فهرست منبع

fix(de-ai): 去掉语料统计结果开头的过程句

模型会把「先核对风格文档」写进正文,过滤时剥掉该前缀。

Co-authored-by: Cursor <cursoragent@cursor.com>
darknessomi 2 هفته پیش
والد
کامیت
29303252c4
2فایلهای تغییر یافته به همراه14 افزوده شده و 1 حذف شده
  1. 7 0
      src/lib/novel/de-ai-output.spec.ts
  2. 7 1
      src/lib/novel/de-ai-output.ts

+ 7 - 0
src/lib/novel/de-ai-output.spec.ts

@@ -55,4 +55,11 @@ describe("filterDeAiOutput", () => {
 
     expect(filterDeAiOutput(output)).toBe(output)
   })
+
+  it("去掉语料统计 skill 诱发的风格文档过程句", () => {
+    const body = "地下暗轨深处,空气沉得像一汪死水。"
+
+    expect(filterDeAiOutput(`先核对工作区是否有风格文档,再按规则逐句处理正文。\n\n${body}`)).toBe(body)
+    expect(filterDeAiOutput(`先核对工作区是否有风格文档,再按规则逐句处理正文。${body}`)).toBe(body)
+  })
 })

+ 7 - 1
src/lib/novel/de-ai-output.ts

@@ -1,10 +1,16 @@
 import { stripThoughtDumpFromText } from "@/lib/thought-dump"
 
+/**
+ * corpus-stat skill asks the model to check style docs first. Some models
+ * write that checklist into the returned body.
+ */
+const STYLE_DOC_PROCESS_PREFIX_RE = /^(?:先核对(?:工作区)?是否有风格文档[,,]再按规则逐句处理正文。\s*)+/
+
 /**
  * Gemini may stream its thought summary as ordinary text instead of a
  * structured `thought` part. Filter the completed payload, where the full
  * thought block can be recognized reliably, before exposing a de-AI result.
  */
 export function filterDeAiOutput(content: string): string {
-  return stripThoughtDumpFromText(content).trim()
+  return stripThoughtDumpFromText(content).trim().replace(STYLE_DOC_PROCESS_PREFIX_RE, "").trim()
 }