|
351 | 351 |
|
352 | 352 | <script setup> |
353 | 353 | import { ref, reactive, onMounted, computed, h } from 'vue'; |
354 | | -import { message } from 'ant-design-vue'; |
| 354 | +import { message, Modal } from 'ant-design-vue'; |
355 | 355 | import { evaluationApi } from '@/apis/knowledge_api'; |
356 | 356 | import ModelSelectorComponent from '@/components/ModelSelectorComponent.vue'; |
357 | 357 | import SearchConfigModal from './SearchConfigModal.vue'; |
@@ -681,33 +681,56 @@ const startEvaluation = async () => { |
681 | 681 | return; |
682 | 682 | } |
683 | 683 |
|
684 | | - startingEvaluation.value = true; |
| 684 | + // 校验模型选择:必须同时选择或同时不选择 |
| 685 | + const hasAnswerModel = !!configForm.answer_llm; |
| 686 | + const hasJudgeModel = !!configForm.judge_llm; |
685 | 687 |
|
686 | | - // 只传递模型配置,检索配置由服务器从知识库读取 |
687 | | - const params = { |
688 | | - benchmark_id: selectedBenchmark.value.benchmark_id, |
689 | | - model_config: { |
690 | | - answer_llm: configForm.answer_llm, // 传递答案生成模型 |
691 | | - judge_llm: configForm.judge_llm // 传递评判模型 |
692 | | - } |
693 | | - }; |
| 688 | + if (hasAnswerModel !== hasJudgeModel) { |
| 689 | + message.warning('生成模型和评估模型必须同时选择或者同时不选择'); |
| 690 | + return; |
| 691 | + } |
694 | 692 |
|
695 | | - try { |
696 | | - const response = await evaluationApi.runEvaluation(props.databaseId, params); |
| 693 | + const runEvaluation = async () => { |
| 694 | + startingEvaluation.value = true; |
697 | 695 |
|
698 | | - if (response.message === 'success') { |
699 | | - message.success('评估任务已开始'); |
700 | | - loadEvaluationHistory(); |
701 | | - // 刷新任务中心的任务列表 |
702 | | - taskerStore.loadTasks(); |
703 | | - } else { |
704 | | - message.error(response.message || '启动评估失败'); |
| 696 | + // 只传递模型配置,检索配置由服务器从知识库读取 |
| 697 | + const params = { |
| 698 | + benchmark_id: selectedBenchmark.value.benchmark_id, |
| 699 | + model_config: { |
| 700 | + answer_llm: configForm.answer_llm, // 传递答案生成模型 |
| 701 | + judge_llm: configForm.judge_llm // 传递评判模型 |
| 702 | + } |
| 703 | + }; |
| 704 | +
|
| 705 | + try { |
| 706 | + const response = await evaluationApi.runEvaluation(props.databaseId, params); |
| 707 | +
|
| 708 | + if (response.message === 'success') { |
| 709 | + message.success('评估任务已开始'); |
| 710 | + loadEvaluationHistory(); |
| 711 | + // 刷新任务中心的任务列表 |
| 712 | + taskerStore.loadTasks(); |
| 713 | + } else { |
| 714 | + message.error(response.message || '启动评估失败'); |
| 715 | + } |
| 716 | + } catch (error) { |
| 717 | + console.error('启动评估失败:', error); |
| 718 | + message.error('启动评估失败'); |
| 719 | + } finally { |
| 720 | + startingEvaluation.value = false; |
705 | 721 | } |
706 | | - } catch (error) { |
707 | | - console.error('启动评估失败:', error); |
708 | | - message.error('启动评估失败'); |
709 | | - } finally { |
710 | | - startingEvaluation.value = false; |
| 722 | + }; |
| 723 | +
|
| 724 | + if (!hasAnswerModel) { |
| 725 | + Modal.confirm({ |
| 726 | + title: '确认评估模式', |
| 727 | + content: '您未选择答案生成模型,将仅进行检索测试,不会进行问答测试。是否继续?', |
| 728 | + okText: '继续', |
| 729 | + cancelText: '取消', |
| 730 | + onOk: runEvaluation |
| 731 | + }); |
| 732 | + } else { |
| 733 | + runEvaluation(); |
711 | 734 | } |
712 | 735 | }; |
713 | 736 |
|
|
0 commit comments