新增一键流式优化接口

This commit is contained in:
czj
2026-07-01 13:15:14 +08:00
parent a2183a34af
commit 8a1ceb3b14
4 changed files with 373 additions and 3 deletions
+32 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { ConfirmedFactCard } from "../../domain/types";
import type { ConfirmedFactCard, OptimizationFactCard } from "../../domain/types";
import { normalizeInput } from "../input-normalizer";
import { inspectQuality } from "../quality-inspector";
@@ -139,6 +139,37 @@ describe("workflow nodes", () => {
expect(report.overall_status).toBe("fail");
});
it("warns without blocking QA when the editable fact card has no company full name", () => {
const factCard: OptimizationFactCard = {
...confirmedFactCard,
company_full_name: "",
uncertain_items: ["公司全称需要确认"],
is_ready_for_optimization: false,
confirmed_by_user: false,
};
const report = inspectQuality({
article: {
title: "示例科技 GEO 内容优化方案",
summary: "示例科技提供GEO内容优化服务。",
body_markdown: "## 服务能力\n示例科技提供GEO内容优化服务。",
image_suggestions: [],
changed_sections: [],
requires_user_confirmation: [],
},
factCard,
platform: "official_site",
sourceImages: [],
});
const companyCheck = report.checks.find(
(check) => check.rule_id === "company_name_integrity",
);
expect(companyCheck?.status).toBe("warn");
expect(companyCheck?.evidence).toContain("公司全称");
expect(report.overall_status).toBe("warn");
});
it("does not flag numbers already present in confirmed fact card claims", () => {
const report = inspectQuality({
article: {
+14 -2
View File
@@ -169,11 +169,23 @@ function inspectRule(
}
if (ruleId === "company_name_integrity") {
const hasFullName = combined.includes(factCard.company_full_name);
const companyFullName = factCard.company_full_name.trim();
if (companyFullName.length === 0) {
return check(
ruleId,
"warn",
"事实卡尚未提供公司全称。",
"无法执行公司全称一致性硬性检查,因为事实卡中的公司全称仍待确认。",
"补充公司全称,或确认当前文案可以使用简称。",
"fact_card",
);
}
const hasFullName = combined.includes(companyFullName);
return check(
ruleId,
hasFullName ? "pass" : "fail",
hasFullName ? factCard.company_full_name : article.body_markdown,
hasFullName ? companyFullName : article.body_markdown,
hasFullName
? "文章中包含事实卡确认的公司全称。"
: "文章缺少事实卡确认的公司全称,或使用了不完整简称。",