fix: 兼容QA检查LLM字段
This commit is contained in:
@@ -182,6 +182,40 @@ describe("domain validation", () => {
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("normalizes near-valid LLM QA report values", () => {
|
||||
const parsed = qaReportSchema.parse({
|
||||
overall_status: "警告",
|
||||
checks: [
|
||||
{
|
||||
rule_id: "标题质量",
|
||||
status: "警告",
|
||||
evidence: { detail: "标题仍然偏营销化" },
|
||||
reason: { reason: "官网标题需要更克制" },
|
||||
suggested_fix: null,
|
||||
target_agent: "",
|
||||
},
|
||||
{
|
||||
rule_id: "company_name_integrity",
|
||||
status: "通过",
|
||||
evidence: "公司全称一致",
|
||||
reason: "正文保留了事实卡中的公司全称",
|
||||
target_agent: "无",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(parsed.overall_status).toBe("warn");
|
||||
expect(parsed.checks[0]).toEqual({
|
||||
rule_id: "title_quality",
|
||||
status: "warn",
|
||||
evidence: "标题仍然偏营销化",
|
||||
reason: "官网标题需要更克制",
|
||||
suggested_fix: "",
|
||||
target_agent: null,
|
||||
});
|
||||
expect(parsed.checks[1]?.target_agent).toBeNull();
|
||||
});
|
||||
|
||||
it("normalizes object-shaped changed sections from LLM output", () => {
|
||||
const parsed = optimizedArticleSchema.parse({
|
||||
title: "Optimized article",
|
||||
|
||||
Reference in New Issue
Block a user