ai-question-pro 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/demo/src/main.vue +141 -123
- package/dist/ai-question-pro.common.js +131 -183
- package/dist/ai-question-pro.common.js.map +1 -1
- package/dist/ai-question-pro.umd.js +131 -183
- package/dist/ai-question-pro.umd.js.map +1 -1
- package/dist/ai-question-pro.umd.min.js +4 -4
- package/dist/ai-question-pro.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,41 +9,41 @@
|
|
|
9
9
|
<img src="../static/logo.png" alt="" style="width: 32px; height: 18px;"/>
|
|
10
10
|
<span>出题</span>
|
|
11
11
|
</div>
|
|
12
|
-
<div class="ai-bot-switch-wrap" style="position: absolute; left: 120px"
|
|
13
|
-
<div class="ai-bot-switch" @click="dropdownVisible = !dropdownVisible"
|
|
14
|
-
<img src="../static/aiBot-icon.png" alt="" style="width: 24px; height: 24px"
|
|
15
|
-
<span class="ai-bot-label"
|
|
16
|
-
{{ currentBot === 'course' ? '课程智能体' : '通义千问' }}
|
|
17
|
-
</span
|
|
18
|
-
<img src="../static/check-icon.png" alt="" style="width: 12px; height: 12px"
|
|
19
|
-
</div
|
|
20
|
-
<div
|
|
21
|
-
v-if="dropdownVisible"
|
|
22
|
-
class="ai-bot-dropdown"
|
|
23
|
-
@mousedown.prevent
|
|
24
|
-
style="position: absolute; z-index: 1000; min-width: 20%;"
|
|
25
|
-
|
|
26
|
-
<div
|
|
27
|
-
class="ai-bot-dropdown-item"
|
|
28
|
-
:class="{ active: currentBot === 'tongyi' }"
|
|
29
|
-
@click="selectBot('tongyi')"
|
|
30
|
-
>通义千问
|
|
31
|
-
</div>
|
|
12
|
+
<!-- <div class="ai-bot-switch-wrap" style="position: absolute; left: 120px">-->
|
|
13
|
+
<!-- <div class="ai-bot-switch" @click="dropdownVisible = !dropdownVisible">-->
|
|
14
|
+
<!-- <img src="../static/aiBot-icon.png" alt="" style="width: 24px; height: 24px">-->
|
|
15
|
+
<!-- <span class="ai-bot-label">-->
|
|
16
|
+
<!-- {{ currentBot === 'course' ? '课程智能体' : '通义千问' }}-->
|
|
17
|
+
<!-- </span>-->
|
|
18
|
+
<!-- <img src="../static/check-icon.png" alt="" style="width: 12px; height: 12px">-->
|
|
19
|
+
<!-- </div>-->
|
|
20
|
+
<!-- <div-->
|
|
21
|
+
<!-- v-if="dropdownVisible"-->
|
|
22
|
+
<!-- class="ai-bot-dropdown"-->
|
|
23
|
+
<!-- @mousedown.prevent-->
|
|
24
|
+
<!-- style="position: absolute; z-index: 1000; min-width: 20%;"-->
|
|
25
|
+
<!-- >-->
|
|
32
26
|
<!-- <div-->
|
|
33
|
-
<!-- v-if="courseId"-->
|
|
34
27
|
<!-- class="ai-bot-dropdown-item"-->
|
|
35
|
-
<!-- :class="{ active: currentBot === '
|
|
36
|
-
<!-- @click="selectBot('
|
|
37
|
-
<!--
|
|
28
|
+
<!-- :class="{ active: currentBot === 'tongyi' }"-->
|
|
29
|
+
<!-- @click="selectBot('tongyi')"-->
|
|
30
|
+
<!-- >通义千问-->
|
|
38
31
|
<!-- </div>-->
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
<!--<!– <div–>-->
|
|
33
|
+
<!--<!– v-if="courseId"–>-->
|
|
34
|
+
<!--<!– class="ai-bot-dropdown-item"–>-->
|
|
35
|
+
<!--<!– :class="{ active: currentBot === 'course' }"–>-->
|
|
36
|
+
<!--<!– @click="selectBot('course')"–>-->
|
|
37
|
+
<!--<!– >课程智能体–>-->
|
|
38
|
+
<!--<!– </div>–>-->
|
|
39
|
+
<!-- </div>-->
|
|
40
|
+
<!-- </div>-->
|
|
41
41
|
</template>
|
|
42
42
|
<div class="add_question_body">
|
|
43
43
|
<div class="question-type-header">
|
|
44
44
|
<span class="required-mark">*</span>
|
|
45
45
|
<span class="section-title">题目类型:</span>
|
|
46
|
-
<span class="tip-text">(
|
|
46
|
+
<span class="tip-text">(为避免您等待时间过长,所选择题型数量总和最好不超过10道</span>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
49
|
<!-- 题目类型列表 -->
|
|
@@ -299,7 +299,7 @@ export default {
|
|
|
299
299
|
{name: '简答题', id: 'shortanswer'},
|
|
300
300
|
],
|
|
301
301
|
difficultyList: [
|
|
302
|
-
{name: '
|
|
302
|
+
{name: '非常简单', id: 0},
|
|
303
303
|
{name: '简单', id: 1},
|
|
304
304
|
{name: '一般', id: 2},
|
|
305
305
|
{name: '困难', id: 3},
|
|
@@ -314,6 +314,8 @@ export default {
|
|
|
314
314
|
joinedQuestions: [], // 存储已加入题库的题目索引
|
|
315
315
|
retryCountMap: {}, // 存储每个题目的重试次数
|
|
316
316
|
isGenerating: false, // 内部loading状态
|
|
317
|
+
typeGeneratedCounts: {}, // 跟踪每个题型已生成的数量
|
|
318
|
+
pendingGenerations: [], // 待生成的题目队列
|
|
317
319
|
}
|
|
318
320
|
},
|
|
319
321
|
watch: {
|
|
@@ -448,6 +450,15 @@ export default {
|
|
|
448
450
|
return this.$message.warning('请至少选择一种题目类型')
|
|
449
451
|
}
|
|
450
452
|
|
|
453
|
+
// 验证选中的题目类型是否都输入了数量
|
|
454
|
+
for (let type of selectedTypes) {
|
|
455
|
+
const count = this.form.typeCounts[type]
|
|
456
|
+
if (!count || count <= 0) {
|
|
457
|
+
const typeName = this.quesTypeList.find(item => item.id === type)?.name || type
|
|
458
|
+
return this.$message.warning(`请为${typeName}输入生成数量`)
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
451
462
|
// 验证是否选择了知识点
|
|
452
463
|
if (!this.form.knowledgeIds) {
|
|
453
464
|
return this.$message.warning('请选择关联知识点')
|
|
@@ -501,39 +512,119 @@ export default {
|
|
|
501
512
|
});
|
|
502
513
|
},
|
|
503
514
|
|
|
504
|
-
|
|
515
|
+
// 重新生成失败的题目 - 需要指定具体的题型和难度
|
|
516
|
+
reSend(failedQuestionType = null, failedDifficulty = null) {
|
|
505
517
|
this.isGenerating = true;
|
|
518
|
+
|
|
519
|
+
// 如果没有指定失败的题型,则需要分析哪个题型还缺少题目
|
|
520
|
+
let targetType = failedQuestionType;
|
|
521
|
+
let targetDifficulty = failedDifficulty;
|
|
522
|
+
|
|
523
|
+
if (!targetType) {
|
|
524
|
+
// 分析哪个题型的数量不足
|
|
525
|
+
const selectedTypes = Object.keys(this.form.selectedTypes).filter(key => this.form.selectedTypes[key]);
|
|
526
|
+
for (let type of selectedTypes) {
|
|
527
|
+
const expectedCount = this.form.typeCounts[type];
|
|
528
|
+
const actualCount = this.typeGeneratedCounts[type] || 0;
|
|
529
|
+
if (actualCount < expectedCount) {
|
|
530
|
+
targetType = type;
|
|
531
|
+
targetDifficulty = this.form.typeDifficulties[type];
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// 如果找不到需要补充的题型,说明数量已经足够
|
|
538
|
+
if (!targetType) {
|
|
539
|
+
this.isGenerating = false;
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// 使用 generateSingleQuestion 方法来生成指定题型
|
|
544
|
+
this.generateSingleQuestion(targetType, targetDifficulty);
|
|
545
|
+
},
|
|
546
|
+
|
|
547
|
+
//发送请求
|
|
548
|
+
sendPost() {
|
|
549
|
+
checkVersion(this.businessSource).then(res => {
|
|
550
|
+
console.log(res);
|
|
551
|
+
if (res.errCode === '403') {
|
|
552
|
+
this.$message.warning(res.errMessage)
|
|
553
|
+
} else {
|
|
554
|
+
this.postQuestion();
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
|
|
559
|
+
postQuestion() {
|
|
560
|
+
this.rebuildFlag = true;
|
|
561
|
+
this.generateCount = 0;
|
|
562
|
+
this.aiResponse = {}
|
|
563
|
+
this.isGenerating = true;
|
|
564
|
+
|
|
565
|
+
// 初始化题型生成计数器
|
|
566
|
+
this.typeGeneratedCounts = {};
|
|
567
|
+
this.pendingGenerations = [];
|
|
568
|
+
|
|
506
569
|
const selectedTypes = Object.keys(this.form.selectedTypes).filter(key => this.form.selectedTypes[key])
|
|
507
|
-
const questionTypes = selectedTypes
|
|
508
|
-
const difficultys = selectedTypes.map(type => this.form.typeDifficulties[type])
|
|
509
570
|
|
|
571
|
+
// 初始化每个题型的计数器和待生成队列
|
|
572
|
+
selectedTypes.forEach(type => {
|
|
573
|
+
this.typeGeneratedCounts[type] = 0;
|
|
574
|
+
const count = this.form.typeCounts[type] || 1;
|
|
575
|
+
|
|
576
|
+
// 将每个需要生成的题目加入队列
|
|
577
|
+
for (let i = 0; i < count; i++) {
|
|
578
|
+
this.pendingGenerations.push({
|
|
579
|
+
type: type,
|
|
580
|
+
difficulty: this.form.typeDifficulties[type],
|
|
581
|
+
index: i
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
// 开始生成题目
|
|
587
|
+
this.pendingGenerations.forEach(item => {
|
|
588
|
+
this.generateSingleQuestion(item.type, item.difficulty);
|
|
589
|
+
});
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
// 生成单个题目的方法
|
|
593
|
+
generateSingleQuestion(questionType, difficulty) {
|
|
510
594
|
let obj = {
|
|
511
595
|
modelType: 'aliyun',
|
|
512
596
|
questionAddCmd: {
|
|
513
|
-
questionTypes:
|
|
597
|
+
questionTypes: [questionType], // 指定单个题型
|
|
514
598
|
count: 1,
|
|
515
599
|
knowledge: this.form.knowledge.join(' '),
|
|
516
600
|
knowledgeId: this.form.knowledgeId[this.form.knowledgeId.length - 1],
|
|
517
|
-
difficultys:
|
|
601
|
+
difficultys: [difficulty],
|
|
518
602
|
prompt: this.form.prompt
|
|
519
603
|
},
|
|
520
604
|
sessionId: this.aiResponse.sessionId ? this.aiResponse.sessionId : '',
|
|
521
605
|
businessSource: this.businessSource,
|
|
522
606
|
courseId: this.courseId,
|
|
523
607
|
}
|
|
524
|
-
|
|
608
|
+
|
|
525
609
|
getAiQuestion(obj).then(res => {
|
|
526
610
|
if (res.success) {
|
|
527
|
-
this.loading && this.loading.close()
|
|
528
611
|
if (res.data && res.data.questions && res.data.questions.length > 0) {
|
|
529
612
|
const newQuestion = res.data.questions[0];
|
|
530
|
-
|
|
613
|
+
|
|
531
614
|
// 检查是否有重复的题目标题和题型
|
|
532
615
|
const isDuplicate = this.checkDuplicateQuestion(newQuestion, questionType);
|
|
533
616
|
|
|
534
617
|
if (isDuplicate) {
|
|
618
|
+
// 重复题目,重新生成
|
|
535
619
|
const repetitionQuestions = this.getGeneratedQuestionsByType(questionType);
|
|
536
|
-
this.
|
|
620
|
+
this.regenerateWithRepetition(obj, repetitionQuestions, questionType);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// 验证返回的题目类型是否正确
|
|
625
|
+
if (newQuestion.type && newQuestion.type !== questionType) {
|
|
626
|
+
console.log(`期望题型: ${questionType}, 实际题型: ${newQuestion.type}, 重新生成`);
|
|
627
|
+
this.generateSingleQuestion(questionType, difficulty);
|
|
537
628
|
return;
|
|
538
629
|
}
|
|
539
630
|
|
|
@@ -545,10 +636,15 @@ export default {
|
|
|
545
636
|
this.$set(newQuestion, 'evaluate', 0)
|
|
546
637
|
// 设置题目类型,便于后续统计
|
|
547
638
|
this.$set(newQuestion, 'type', questionType)
|
|
639
|
+
|
|
640
|
+
// 更新该题型的生成计数
|
|
641
|
+
this.typeGeneratedCounts[questionType]++;
|
|
642
|
+
|
|
548
643
|
this.showGenerateResult();
|
|
549
644
|
} else {
|
|
550
645
|
this.$message.warning('题目获取失败,重新生成中...')
|
|
551
|
-
|
|
646
|
+
// 重新生成指定题型
|
|
647
|
+
this.generateSingleQuestion(questionType, difficulty);
|
|
552
648
|
}
|
|
553
649
|
} else {
|
|
554
650
|
this.isGenerating = false;
|
|
@@ -563,91 +659,6 @@ export default {
|
|
|
563
659
|
})
|
|
564
660
|
},
|
|
565
661
|
|
|
566
|
-
//发送请求
|
|
567
|
-
sendPost() {
|
|
568
|
-
checkVersion(this.businessSource).then(res => {
|
|
569
|
-
console.log(res);
|
|
570
|
-
if (res.errCode === '403') {
|
|
571
|
-
this.$message.warning(res.errMessage)
|
|
572
|
-
} else {
|
|
573
|
-
this.postQuestion();
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
},
|
|
577
|
-
|
|
578
|
-
postQuestion() {
|
|
579
|
-
this.rebuildFlag = true;
|
|
580
|
-
this.generateCount = 0;
|
|
581
|
-
this.aiResponse = {}
|
|
582
|
-
this.isGenerating = true;
|
|
583
|
-
|
|
584
|
-
const selectedTypes = Object.keys(this.form.selectedTypes).filter(key => this.form.selectedTypes[key])
|
|
585
|
-
|
|
586
|
-
// 按题型分别生成题目
|
|
587
|
-
selectedTypes.forEach(type => {
|
|
588
|
-
const count = this.form.typeCounts[type] || 1;
|
|
589
|
-
const difficulty = this.form.typeDifficulties[type];
|
|
590
|
-
|
|
591
|
-
// 为每种题型生成指定数量的题目
|
|
592
|
-
for (let i = 0; i < count; i++) {
|
|
593
|
-
let obj = {
|
|
594
|
-
modelType: 'aliyun',
|
|
595
|
-
questionAddCmd: {
|
|
596
|
-
questionTypes: [type], // 单个题型
|
|
597
|
-
count: 1,
|
|
598
|
-
knowledge: this.form.knowledge.join(' '),
|
|
599
|
-
knowledgeId: this.form.knowledgeId[this.form.knowledgeId.length - 1],
|
|
600
|
-
difficultys: [difficulty], // 对应的难度
|
|
601
|
-
prompt: this.form.prompt
|
|
602
|
-
},
|
|
603
|
-
sessionId: this.aiResponse.sessionId ? this.aiResponse.sessionId : '',
|
|
604
|
-
businessSource: this.businessSource,
|
|
605
|
-
courseId: this.courseId,
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
getAiQuestion(obj).then(res => {
|
|
609
|
-
if (res.success) {
|
|
610
|
-
if (res.data && res.data.questions && res.data.questions.length > 0) {
|
|
611
|
-
const newQuestion = res.data.questions[0];
|
|
612
|
-
|
|
613
|
-
// 检查是否有重复的题目标题和题型
|
|
614
|
-
const isDuplicate = this.checkDuplicateQuestion(newQuestion, type);
|
|
615
|
-
|
|
616
|
-
if (isDuplicate) {
|
|
617
|
-
// 只传递当前题型
|
|
618
|
-
const repetitionQuestions = this.getGeneratedQuestionsByType(type);
|
|
619
|
-
this.regenerateWithRepetition(obj, repetitionQuestions, type);
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
if (this.aiResponse.questions && this.aiResponse.questions.length > 0) {
|
|
624
|
-
this.aiResponse.questions.push(newQuestion);
|
|
625
|
-
} else {
|
|
626
|
-
this.aiResponse = res.data;
|
|
627
|
-
}
|
|
628
|
-
this.$set(newQuestion, 'evaluate', 0)
|
|
629
|
-
// 设置题目类型,便于后续统计
|
|
630
|
-
this.$set(newQuestion, 'type', type)
|
|
631
|
-
this.showGenerateResult();
|
|
632
|
-
} else {
|
|
633
|
-
this.$message.warning('题目获取失败,重新生成中...')
|
|
634
|
-
return this.reSend()
|
|
635
|
-
}
|
|
636
|
-
} else {
|
|
637
|
-
this.isGenerating = false;
|
|
638
|
-
this.$message.warning('题目获取失败')
|
|
639
|
-
this.rebuildFlag = false;
|
|
640
|
-
}
|
|
641
|
-
}).catch(error => {
|
|
642
|
-
console.log("error:" + error);
|
|
643
|
-
this.isGenerating = false;
|
|
644
|
-
this.$message.warning('题目获取失败')
|
|
645
|
-
this.rebuildFlag = false;
|
|
646
|
-
})
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
},
|
|
650
|
-
|
|
651
662
|
//获取知识点名称
|
|
652
663
|
getKnowledgeName(e, array) {
|
|
653
664
|
array.forEach(item => {
|
|
@@ -839,6 +850,13 @@ export default {
|
|
|
839
850
|
this.$set(newQuestion, 'evaluate', 0)
|
|
840
851
|
// 设置题目类型,便于后续统计
|
|
841
852
|
this.$set(newQuestion, 'type', questionType)
|
|
853
|
+
|
|
854
|
+
// 更新该题型的生成计数
|
|
855
|
+
if (!this.typeGeneratedCounts[questionType]) {
|
|
856
|
+
this.typeGeneratedCounts[questionType] = 0;
|
|
857
|
+
}
|
|
858
|
+
this.typeGeneratedCounts[questionType]++;
|
|
859
|
+
|
|
842
860
|
this.showGenerateResult();
|
|
843
861
|
} else {
|
|
844
862
|
this.$message.warning('重新生成题目失败')
|