fix: 收紧LLM输出格式提示
This commit is contained in:
@@ -47,6 +47,14 @@ describe("LLM prompt builders", () => {
|
||||
expect(prompt).toContain("图片主题");
|
||||
});
|
||||
|
||||
it("fact extraction prompt explicitly forbids object items in string arrays", () => {
|
||||
const prompt = `${FACT_EXTRACTOR_SYSTEM_PROMPT}\n${buildFactExtractorPrompt(articleInput)}`;
|
||||
|
||||
expect(prompt).toContain("uncertain_items must be string[]");
|
||||
expect(prompt).toContain("core_claims must be string[]");
|
||||
expect(prompt).toContain("Do not return objects inside string arrays");
|
||||
});
|
||||
|
||||
it("article optimizer prompt includes platform templates and Chinese output rules", () => {
|
||||
const prompt = `${ARTICLE_OPTIMIZER_SYSTEM_PROMPT}\n${buildArticleOptimizerPrompt(articleInput, factCard)}`;
|
||||
|
||||
@@ -60,6 +68,14 @@ describe("LLM prompt builders", () => {
|
||||
expect(prompt).toContain("forbidden_claims");
|
||||
});
|
||||
|
||||
it("article optimizer prompt explicitly describes optional array shapes", () => {
|
||||
const prompt = `${ARTICLE_OPTIMIZER_SYSTEM_PROMPT}\n${buildArticleOptimizerPrompt(articleInput, factCard)}`;
|
||||
|
||||
expect(prompt).toContain("changed_sections must be string[]");
|
||||
expect(prompt).toContain("requires_user_confirmation must be string[]");
|
||||
expect(prompt).toContain("image_suggestions must be []");
|
||||
});
|
||||
|
||||
it("quality inspector prompt encodes fail and warn standards for all risk gates", () => {
|
||||
const prompt = `${QUALITY_INSPECTOR_SYSTEM_PROMPT}\n${buildQualityInspectorPrompt({
|
||||
article: {
|
||||
@@ -92,6 +108,35 @@ describe("LLM prompt builders", () => {
|
||||
expect(prompt).toContain("warn 标准");
|
||||
});
|
||||
|
||||
it("quality inspector prompt explicitly describes enum outputs", () => {
|
||||
const prompt = `${QUALITY_INSPECTOR_SYSTEM_PROMPT}\n${buildQualityInspectorPrompt({
|
||||
article: {
|
||||
title: "伟思德鲁 AIGC短视频培训",
|
||||
summary: "官网文章摘要",
|
||||
body_markdown: "正文",
|
||||
image_suggestions: [],
|
||||
changed_sections: [],
|
||||
requires_user_confirmation: [],
|
||||
},
|
||||
factCard,
|
||||
platform: "official_site",
|
||||
deterministicChecks: [
|
||||
{
|
||||
rule_id: "title_quality",
|
||||
status: "pass",
|
||||
evidence: "标题自然",
|
||||
reason: "本地规则通过",
|
||||
suggested_fix: "",
|
||||
target_agent: null,
|
||||
},
|
||||
],
|
||||
})}`;
|
||||
|
||||
expect(prompt).toContain("status must be one of pass, warn, fail");
|
||||
expect(prompt).toContain("rule_id must reuse the exact English rule_id");
|
||||
expect(prompt).toContain("target_agent must be title, body, fact_card, or null");
|
||||
});
|
||||
|
||||
it("targeted rewrite prompt gives rule-specific repair actions", () => {
|
||||
const prompt = `${TARGETED_REWRITER_SYSTEM_PROMPT}\n${buildTargetedRewritePrompt({
|
||||
article: {
|
||||
|
||||
Reference in New Issue
Block a user