更新了模型评估页面的新建
This commit is contained in:
@@ -305,18 +305,13 @@
|
||||
<div class="mb-6" id="evalRulesSection">
|
||||
<h3 class="text-sm font-semibold text-gray-700 mb-4 pb-2 border-b border-gray-100">评测规则</h3>
|
||||
<div class="flex items-center">
|
||||
<select name="eval_dimension" class="form-select flex-1 max-w-md">
|
||||
<select name="eval_dimension" id="dimensionSelect" class="form-select flex-1 max-w-md">
|
||||
<option value="">请选择评测维度</option>
|
||||
<option value="accuracy">准确率</option>
|
||||
<option value="recall">召回率</option>
|
||||
<option value="f1">F1值</option>
|
||||
<option value="bleu">BLEU</option>
|
||||
<option value="rouge">ROUGE</option>
|
||||
</select>
|
||||
<button type="button" class="ml-2 text-primary text-sm flex items-center hover:text-primary/80">
|
||||
<button type="button" class="ml-2 text-primary text-sm flex items-center hover:text-primary/80" onclick="loadDimensions()">
|
||||
<i class="fa fa-refresh"></i>
|
||||
</button>
|
||||
<button type="button" class="ml-3 bg-white border border-primary text-primary rounded px-3 py-1.5 text-sm hover:bg-primary/5">
|
||||
<button type="button" class="ml-3 bg-white border border-primary text-primary rounded px-3 py-1.5 text-sm hover:bg-primary/5" onclick="window.location.href='model-dimension-create.html'">
|
||||
+ 创建评测维度
|
||||
</button>
|
||||
</div>
|
||||
@@ -384,6 +379,9 @@
|
||||
// 加载评测数据集
|
||||
loadTestDatasets();
|
||||
|
||||
// 加载评测维度
|
||||
loadDimensions();
|
||||
|
||||
// 设置侧边栏当前页高亮
|
||||
const currentPage = 'model-eval';
|
||||
document.querySelectorAll('.nav-link').forEach(link => {
|
||||
@@ -510,6 +508,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 加载评测维度列表
|
||||
async function loadDimensions() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/dimension`);
|
||||
const result = await response.json();
|
||||
if (result.code === 0 && result.data) {
|
||||
const select = document.getElementById('dimensionSelect');
|
||||
select.innerHTML = '<option value="">请选择评测维度</option>' +
|
||||
result.data.map(d => `<option value="${d.id}">${d.name} (${getDimensionTypeName(d.type)})</option>`).join('');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载评测维度失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取评测维度类型名称
|
||||
function getDimensionTypeName(type) {
|
||||
const typeMap = {
|
||||
'classification': '分类',
|
||||
'metric': '指标',
|
||||
'text_similarity': '文本相似度'
|
||||
};
|
||||
return typeMap[type] || type || '未知';
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
async function submitForm() {
|
||||
const form = document.getElementById('evalForm');
|
||||
@@ -518,6 +541,8 @@
|
||||
name: formData.get('name'),
|
||||
eval_type: formData.get('eval_type'),
|
||||
model_id: formData.get('model_id'),
|
||||
dataset_id: formData.get('dataset_id'),
|
||||
eval_dimension: formData.get('eval_dimension'),
|
||||
data_source: formData.get('data_source'),
|
||||
leaderboard: formData.get('leader') === 'on'
|
||||
};
|
||||
@@ -530,6 +555,14 @@
|
||||
showMessage('提示', '请选择评测模型', 'warning');
|
||||
return;
|
||||
}
|
||||
if (!data.dataset_id) {
|
||||
showMessage('提示', '请选择评测数据集', 'warning');
|
||||
return;
|
||||
}
|
||||
if (!data.eval_dimension) {
|
||||
showMessage('提示', '请选择评测维度', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/model-eval`, {
|
||||
|
||||
Reference in New Issue
Block a user