Question generation: scenario-based 3-step prompt with technique labeling, key_points constrained to KB source, temperature 0.1. Generator node: two-step extraction prompt for assessment flow.

This commit is contained in:
Developer
2026-05-20 17:33:28 +08:00
parent 83483d8117
commit 17ddfa83bf
3 changed files with 83 additions and 95 deletions
@@ -89,96 +89,82 @@ export const questionGeneratorNode = async (
.map((q, i) => `Q${i + 1}: ${q.questionText}`)
.join('\n');
const systemPromptZh = `你是一位严格的知识评估专家。你必须**仅基于**下方提供的知识库内容来生成测试题目
const systemPromptZh = `你是一个信息提取工具。严格按以下步骤操作
### 核心铁律(违反将导致题目无效):
1. **所有题目必须直接来源于提供的知识库内容**,每个题目必须能找到对应的原文依据
2. **绝对禁止**编造知识库内容中未提及的概念、术语、流程或数据
3. **绝对禁止**使用你自身知识库中的内容来编造题目
4. 如果知识库内容不足以出题,诚实地报告而不是编造
### 第一步:提取知识点
阅读下方 Human 消息中的【知识库内容】,逐条列出其中包含的所有可考核知识点。
每条以"知识点N:"开头,引用原文语句。如果不足,诚实报告。
### 强制性语言规则:
**必须使用中文 (Simplified Chinese) 进行回复**
### 第二步:从知识点生成考题
仅用第一步提取的知识点生成 1 道题。必须引用知识点编号
### 多样性规则
${rulesZh}
### 绝对禁止
- 禁止使用知识库内容中不存在的任何概念、术语、数据
- 禁止使用你自己的知识
${existingQuestionsText ? `- 禁止与已出题目重复:${existingQuestionsText}` : ''}
### 禁止重复列表(已出过):
${existingQuestionsText || '无'}
### 任务:
${hasKeywords ? `目标关键词:${keywordText}\n` : ''}出题风格:${style}
难度:${difficultyText}
请以 JSON 数组格式返回 1 个问题:
### 输出(纯 JSON 数组):
[
{
"question_text": "...",
"key_points": ["点1", "点2"],
"difficulty": "...",
"dimension": "prompt/llm/ide/devPattern/workCapability",
"basis": "【必须填写】从知识库中引用与此题相关的原文内容,用引号标注来源段落"
"knowledge_points": ["知识点引用"],
"question_text": "基于知识点的题目",
"key_points": ["评分要点"],
"difficulty": "STANDARD|ADVANCED|SPECIALIST",
"dimension": "prompt|llm|ide|devPattern|workCapability",
"basis": "知识库原文"
}
]`;
// dimension取值:prompt=提示词, llm=LLM原理, ide=IDE协作, devPattern=开发范式, workCapability=工作能力
const systemPromptJa = `あなたは厳格な知識評価の専門家です。提供されたナレッジベースの内容**のみ**に基づいて問題を作成してください。
const systemPromptJa = `あなたは情報抽出ツールです。以下の手順に厳密に従ってください。
### 核心鉄則(違反した問題は無効):
1. **すべての問題は提供されたナレッジベースから直接導出**し、各問題に原文の根拠が必要
2. **絶対禁止**:ナレッジベースに記載されていない概念、用語、プロセス、データを作り出すこと
3. **絶対禁止**:自身の知識ベースの内容を問題として使用すること
4. 内容が不十分な場合は、正直に報告し、捏造しないこと
### 第一歩:知識ポイントの抽出
Human メッセージ内の【ナレッジベース内容】を読み、含まれるすべての評価可能な知識ポイントを箇条書きで抽出。
各項目は「知識ポイントN:」で始め、原文を引用。不足している場合は正直に報告。
### 言語ルール(最重要):
**必ず日本語で作成してください**。中国語が混ざらないように厳格に注意してください
### 第二歩:知識ポイントから問題を作成
第一歩で抽出した知識ポイントのみを使用して 1 問作成。知識ポイント番号を引用すること
### 多様性ルール
${rulesJa}
### 絶対禁止
- ナレッジベースに存在しない概念、用語、データの使用
- 自身の知識の使用
${existingQuestionsText ? `- 作成済み問題との重複禁止:${existingQuestionsText}` : ''}
### 作成済み問題リスト
${existingQuestionsText || 'なし'}
### 任務:
${hasKeywords ? `目標キーワード:${keywordText}\n` : ''}出題スタイル:${style}
難易度:${difficultyText}
以下のJSON配列形式で問題を1つ返してください:
### 出力(純粋な JSON 配列)
[
{
"question_text": "...",
"key_points": ["ポイント1", "ポイント2"],
"difficulty": "...",
"dimension": "prompt/llm/ide/devPattern/workCapability",
"basis": "【必須】ナレッジベースから関連する原文を引用し、出典段落を明記"
"knowledge_points": ["知識ポイント参照"],
"question_text": "知識ポイントに基づく問題",
"key_points": ["採点ポイント"],
"difficulty": "STANDARD|ADVANCED|SPECIALIST",
"dimension": "prompt|llm|ide|devPattern|workCapability",
"basis": "ナレッジベースの原文"
}
]`;
const systemPromptEn = `You are a strict knowledge assessment expert. You MUST generate questions **ONLY** from the provided knowledge base content below.
const systemPromptEn = `You are an information extraction tool. Follow these steps exactly.
### 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
### Step 1: Extract Knowledge Points
Read the knowledge base content in the Human message. List ALL assessable knowledge points found.
Each point must start with "KP N:" and quote the source text. If insufficient, honestly report.
### Language Rule:
**You MUST generate the question and key points in English.**
### Step 2: Generate Question from Points
Use ONLY the knowledge points from Step 1 to generate 1 question. Must reference KP numbers.
### Diversity Rules:
${rulesEn}
### Absolutely Forbidden:
- Using any concept, term, or data NOT present in the knowledge base content
- Using your own knowledge
${existingQuestionsText ? `- Repeating previous questions: ${existingQuestionsText}` : ''}
### Previous Questions (DO NOT REPEAT):
${existingQuestionsText || 'None'}
Return 1 question as a JSON array with format:
### Output (pure JSON array only):
[
{
"question_text": "...",
"key_points": ["point1", "point2"],
"difficulty": "...",
"dimension": "prompt/llm/ide/devPattern/workCapability",
"basis": "【REQUIRED】Cite the specific source text from the knowledge base, noting the source paragraph"
"knowledge_points": ["KP reference"],
"question_text": "Question based on the knowledge points",
"key_points": ["scoring points"],
"difficulty": "STANDARD|ADVANCED|SPECIALIST",
"dimension": "prompt|llm|ide|devPattern|workCapability",
"basis": "Source text from knowledge base"
}
]`;