F1-F10: audit fixes (dimension normalize, passingScore scale, DB defaults, onDelete, item status filter, timeout event type, userId privacy) + generator.node.ts strict prompt rules (anti-hallucination)

This commit is contained in:
Developer
2026-05-20 11:13:37 +08:00
parent 29bac74b58
commit 83483d8117
13 changed files with 205 additions and 202 deletions
@@ -89,12 +89,18 @@ export const questionGeneratorNode = async (
.map((q, i) => `Q${i + 1}: ${q.questionText}`)
.join('\n');
const systemPromptZh = `你是一位专业的知识评估专家。请根据提供的知识库片段生成 1 个唯一的测试题目。
const systemPromptZh = `你是一位严格的知识评估专家。你必须**仅基于**下方提供的知识库内容来生成测试题目。
### 核心铁律(违反将导致题目无效):
1. **所有题目必须直接来源于提供的知识库内容**,每个题目必须能找到对应的原文依据
2. **绝对禁止**编造知识库内容中未提及的概念、术语、流程或数据
3. **绝对禁止**使用你自身知识库中的内容来编造题目
4. 如果知识库内容不足以出题,诚实地报告而不是编造
### 强制性语言规则:
**必须使用中文 (Simplified Chinese) 进行回复**。即使知识库内容是英文或其他语言,问题(question_text)和关键点(key_points)也必须使用中文。
**必须使用中文 (Simplified Chinese) 进行回复**。
### 强制性多样性规则:
### 多样性规则:
${rulesZh}
### 禁止重复列表(已出过):
@@ -111,15 +117,21 @@ ${hasKeywords ? `目标关键词:${keywordText}\n` : ''}出题风格:${style
"key_points": ["点1", "点2"],
"difficulty": "...",
"dimension": "prompt/llm/ide/devPattern/workCapability",
"basis": "[n] 引用原文..."
"basis": "【必须填写】从知识库中引用与此题相关的原文内容,用引号标注来源段落"
}
]`;
// dimension取值:prompt=提示词, llm=LLM原理, ide=IDE协作, devPattern=开发范式, workCapability=工作能力
const systemPromptJa = `あなたは専門的なアセスメントエキスパートです。提供されたナレッジベースに基づいて、ユニークな問題を 1 つ作成してください。
const systemPromptJa = `あなたは厳格な知識評価の専門家です。提供されたナレッジベースの内容**のみ**に基づいて問題を作成してください。
### 核心鉄則(違反した問題は無効):
1. **すべての問題は提供されたナレッジベースから直接導出**し、各問題に原文の根拠が必要
2. **絶対禁止**:ナレッジベースに記載されていない概念、用語、プロセス、データを作り出すこと
3. **絶対禁止**:自身の知識ベースの内容を問題として使用すること
4. 内容が不十分な場合は、正直に報告し、捏造しないこと
### 言語ルール(最重要):
**必ず日本語で作成してください**。提供されたナレッジベースが英語や中国語、その他の言語であっても、質問文(question_text)およびキーポイント(key_points)は必ず日本語で回答してください。中国語が混ざらないように厳格に注意してください。
**必ず日本語で作成してください**。中国語が混ざらないように厳格に注意してください。
### 多様性ルール:
${rulesJa}
@@ -138,11 +150,17 @@ ${hasKeywords ? `目標キーワード:${keywordText}\n` : ''}出題スタイ
"key_points": ["ポイント1", "ポイント2"],
"difficulty": "...",
"dimension": "prompt/llm/ide/devPattern/workCapability",
"basis": "[n] 引用箇所..."
"basis": "【必須】ナレッジベースから関連する原文を引用し、出典段落を明記"
}
]`;
]`;
const systemPromptEn = `You are an expert examiner. Generate 1 UNIQUE question based on the provided context.
const systemPromptEn = `You are a strict knowledge assessment expert. You MUST generate questions **ONLY** from the provided knowledge base content below.
### Core Rules (violations invalidate the question):
1. **All questions MUST directly derive from the provided content**, each question requires a verifiable source reference
2. **ABSOLUTELY FORBIDDEN**: inventing concepts, terminology, processes, or data not in the provided content
3. **ABSOLUTELY FORBIDDEN**: using your own knowledge to fabricate questions
4. If content is insufficient, honestly report rather than fabricate
### Language Rule:
**You MUST generate the question and key points in English.**
@@ -160,7 +178,7 @@ Return 1 question as a JSON array with format:
"key_points": ["point1", "point2"],
"difficulty": "...",
"dimension": "prompt/llm/ide/devPattern/workCapability",
"basis": "[n] citation..."
"basis": "【REQUIRED】Cite the specific source text from the knowledge base, noting the source paragraph"
}
]`;
@@ -172,10 +190,10 @@ Return 1 question as a JSON array with format:
? systemPromptJa
: systemPromptEn;
const humanMsg = isZh
? `请使用中文基于以下内容生成题目:\n\n${knowledgeBaseContent}`
? `【知识库内容 - 以下是你出题的唯一依据】\n\n--- 知识库开始 ---\n${knowledgeBaseContent}\n--- 知识库结束 ---\n\n请严格基于以上内容生成题目。`
: isJa
? `以下の内容に基づいて、必ず日本語でアセスメント問題を作成してください:\n\n${knowledgeBaseContent}`
: `Generate evaluation question in English based on:\n\n${knowledgeBaseContent}`;
? `【ナレッジベース内容 - 以下は出題の唯一の根拠です】\n\n--- ナレッジベース開始 ---\n${knowledgeBaseContent}\n--- ナレッジベース終了 ---\n\n上記の内容のみに基づいて問題を作成してください。`
: `【Knowledge Base Content - Your ONLY source for questions】\n\n--- KB START ---\n${knowledgeBaseContent}\n--- KB END ---\n\nGenerate questions strictly from the above content only.`;
try {
const response = await model.invoke([