forked from hangshuo652/aurak
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:
@@ -92,7 +92,7 @@ export class QuestionBankService {
|
||||
}
|
||||
if (createDto.templateId) {
|
||||
const existing = await this.bankRepository.findOne({
|
||||
where: { templateId: createDto.templateId, tenantId: tenantId as any },
|
||||
where: { templateId: createDto.templateId },
|
||||
});
|
||||
if (existing) {
|
||||
if (existing.status === QuestionBankStatus.DRAFT || existing.status === QuestionBankStatus.REJECTED) {
|
||||
@@ -295,35 +295,45 @@ export class QuestionBankService {
|
||||
const model = new ChatOpenAI({
|
||||
apiKey: modelConfig.apiKey || 'ollama',
|
||||
modelName: modelConfig.modelId,
|
||||
temperature: 0.7,
|
||||
temperature: 0.3,
|
||||
configuration: {
|
||||
baseURL: modelConfig.baseUrl || 'https://api.deepseek.com/v1',
|
||||
},
|
||||
});
|
||||
|
||||
const systemPrompt = `你是一位专业的知识评估专家。请根据提供的知识库片段生成 ${count} 个唯一的测试题目。
|
||||
const systemPrompt = `你是一位严格的知识评估专家。你必须**仅基于**下方 Human 消息中提供的【知识库内容】来生成题目。
|
||||
|
||||
### 强制性语言规则:
|
||||
**必须使用中文 (Simplified Chinese) 进行回复**。即使知识库内容是英文或其他语言,问题(question_text)和关键点(key_points)也必须使用中文。
|
||||
### 核心铁律(违反将导致题目无效):
|
||||
1. **所有题目必须直接来源于提供的知识库内容**,每个题目必须能找到对应的原文依据
|
||||
2. **绝对禁止**编造知识库内容中未提及的概念、术语、流程或数据
|
||||
3. **绝对禁止**使用你自身知识库中的内容来编造题目
|
||||
4. 如果知识库内容不足以生成 ${count} 道有意义的题目,可以生成少于 ${count} 道,但题目质量优先
|
||||
|
||||
### 多样性规则:
|
||||
1. 禁止重复:绝对禁止生成相似的题目
|
||||
2. 深度挖掘:从不同的角度出题,如流程、限制、优缺点、具体参数等
|
||||
3. 随机扰动:从不同的逻辑链条出发
|
||||
|
||||
### 任务:
|
||||
请以 JSON 数组格式返回 ${count} 个问题:
|
||||
### 格式要求:
|
||||
请以 JSON 数组格式返回题目:
|
||||
[
|
||||
{
|
||||
"question_text": "问题内容",
|
||||
"key_points": ["要点1", "要点2"],
|
||||
"question_text": "基于知识库内容的实际问题",
|
||||
"key_points": ["评分要点1", "评分要点2"],
|
||||
"difficulty": "STANDARD|ADVANCED|SPECIALIST",
|
||||
"dimension": "prompt|llm|ide|devPattern|workCapability",
|
||||
"basis": "[n] 引用原文..."
|
||||
"basis": "【必须填写】从知识库中引用与此题相关的原文内容,用引号标注来源段落"
|
||||
}
|
||||
]`;
|
||||
]
|
||||
|
||||
const humanMsg = `请使用中文基于以下内容生成题目:\n\n${knowledgeBaseContent}`;
|
||||
### 维度说明(根据题目内容归类):
|
||||
- prompt: 关于提示词设计、AI交互优化
|
||||
- llm: 关于大语言模型原理、架构、参数
|
||||
- ide: 关于开发工具使用、协作效率
|
||||
- devPattern: 关于开发方法论、工程范式
|
||||
- workCapability: 关于工作能力、综合素养
|
||||
|
||||
### 出题规范:
|
||||
1. 每个题目必须标注 basis,引用知识库中的具体原文作为依据
|
||||
2. 题目难度分布合理,覆盖 STANDARD/ADVANCED/SPECIALIST
|
||||
3. 不同维度各出一部分,不要集中在一个维度`;
|
||||
|
||||
const humanMsg = `【知识库内容 - 以下是你出题的唯一依据】\n\n--- 知识库开始 ---\n${knowledgeBaseContent}\n--- 知识库结束 ---\n\n请严格基于以上知识库内容生成题目。`;
|
||||
|
||||
try {
|
||||
const response = await model.invoke([
|
||||
@@ -395,7 +405,7 @@ export class QuestionBankService {
|
||||
}
|
||||
|
||||
const allItems = await this.itemRepository.find({
|
||||
where: { bankId },
|
||||
where: { bankId, status: QuestionBankItemStatus.PUBLISHED },
|
||||
});
|
||||
|
||||
if (allItems.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user