Skip to content

Commit 386c5d5

Browse files
committed
feat: 添加模型选择校验,确保生成模型和评估模型同时选择或同时不选择
1 parent 5047cd0 commit 386c5d5

File tree

1 file changed

+47
-24
lines changed

1 file changed

+47
-24
lines changed

web/src/components/RAGEvaluationTab.vue

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351

352352
<script setup>
353353
import { ref, reactive, onMounted, computed, h } from 'vue';
354-
import { message } from 'ant-design-vue';
354+
import { message, Modal } from 'ant-design-vue';
355355
import { evaluationApi } from '@/apis/knowledge_api';
356356
import ModelSelectorComponent from '@/components/ModelSelectorComponent.vue';
357357
import SearchConfigModal from './SearchConfigModal.vue';
@@ -681,33 +681,56 @@ const startEvaluation = async () => {
681681
return;
682682
}
683683
684-
startingEvaluation.value = true;
684+
// 校验模型选择:必须同时选择或同时不选择
685+
const hasAnswerModel = !!configForm.answer_llm;
686+
const hasJudgeModel = !!configForm.judge_llm;
685687
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+
}
694692
695-
try {
696-
const response = await evaluationApi.runEvaluation(props.databaseId, params);
693+
const runEvaluation = async () => {
694+
startingEvaluation.value = true;
697695
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;
705721
}
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();
711734
}
712735
};
713736

0 commit comments

Comments
 (0)