fix: 兼容事实卡LLM字段形状
This commit is contained in:
@@ -77,6 +77,42 @@ describe("domain validation", () => {
|
||||
expect(numericExperience.experience_years).toBe(8);
|
||||
});
|
||||
|
||||
it("normalizes object-shaped and single-string LLM fact card fields", () => {
|
||||
const parsed = candidateFactCardSchema.parse({
|
||||
company_full_name: { name: "示例科技有限公司" },
|
||||
company_short_names: "示例科技",
|
||||
brand_names: [{ name: "示例品牌" }],
|
||||
product_names: [{ product: "GEO内容优化平台" }],
|
||||
target_industry: { industry: "GEO内容优化" },
|
||||
target_audience: { audience: "市场团队" },
|
||||
experience_years: { years: "8年" },
|
||||
core_claims: [
|
||||
{ claim: "提供GEO内容优化服务", source: "原文明确出现" },
|
||||
],
|
||||
forbidden_claims: [
|
||||
{ claim: "行业第一", reason: "缺少第三方依据" },
|
||||
],
|
||||
image_topics: [{ topic: "产品后台截图" }],
|
||||
uncertain_items: [
|
||||
{ item: "客户案例", reason: "原文没有给出客户名称" },
|
||||
{ claim: "出海能力", evidence: "只出现营销表述" },
|
||||
],
|
||||
});
|
||||
|
||||
expect(parsed.company_full_name).toBe("示例科技有限公司");
|
||||
expect(parsed.company_short_names).toEqual(["示例科技"]);
|
||||
expect(parsed.brand_names).toEqual(["示例品牌"]);
|
||||
expect(parsed.product_names).toEqual(["GEO内容优化平台"]);
|
||||
expect(parsed.target_industry).toBe("GEO内容优化");
|
||||
expect(parsed.target_audience).toBe("市场团队");
|
||||
expect(parsed.experience_years).toBe(8);
|
||||
expect(parsed.core_claims).toEqual(["提供GEO内容优化服务"]);
|
||||
expect(parsed.forbidden_claims).toEqual(["行业第一"]);
|
||||
expect(parsed.image_topics).toEqual(["产品后台截图"]);
|
||||
expect(parsed.uncertain_items).toEqual(["客户案例", "出海能力"]);
|
||||
expect(parsed.is_ready_for_optimization).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps incomplete candidate fact cards editable and ready", () => {
|
||||
const parsed = candidateFactCardSchema.parse({
|
||||
company_full_name: "",
|
||||
|
||||
Reference in New Issue
Block a user