fix: 推理/评测结果同步、数据集统计与算力节点管理增强
后端: - 抽取 fetch_eval_result_content 复用函数,model_eval_detail 直接应用评测任务结果 - health 接口移除数据库依赖,返回静态指标 - 数据集: count_dataset_records JSON 感知计数; 文件统计改为从 dataset_files 聚合重算; 在线编辑记录 size/record_count/version_no; 上传同步批处理 - 算力节点: 调度支持 requested GPU 子集校验与容量计算; 新增 delete_compute_node(含活动任务保护)及 DELETE 接口; 连接池 connect_timeout - 评测任务落库 basic_metrics/score/completed_time, failed/stopped 记录 error 评测引擎: - _load_dataset 支持 JSON/JSONL 文件 - 新增 exact match 与文本相似度指标, 余弦相似度去掉 2 样本限制 前端: - 算力节点列表「维护」改为「删除」(带确认弹窗), compute.ts 新增 deleteComputeNode - 数据集上传超时调整为 120s; FineTuneTask 增加 compute_node_id; GpuInfo 状态增加 reserved
This commit is contained in:
@@ -50,6 +50,20 @@ const rules: FormRules = {
|
||||
}
|
||||
|
||||
/** 处理文件选择(替换模式:新文件覆盖旧文件) */
|
||||
function parseDatasetRecordValues(text: string, fileName: string): unknown[] {
|
||||
const content = text.trim()
|
||||
if (!content) return []
|
||||
if (fileName.toLowerCase().endsWith('.json')) {
|
||||
const parsed = JSON.parse(content)
|
||||
return Array.isArray(parsed) ? parsed : [parsed]
|
||||
}
|
||||
return content
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean)
|
||||
.map((line) => JSON.parse(line))
|
||||
}
|
||||
|
||||
async function handleFileChange(uploadFile: UploadFile) {
|
||||
const raw = uploadFile.raw
|
||||
if (!raw) return
|
||||
@@ -70,25 +84,19 @@ async function handleFileChange(uploadFile: UploadFile) {
|
||||
async function analyzeFile(file: File) {
|
||||
try {
|
||||
const text = await file.text()
|
||||
const lines = text.trim().split('\n').filter(Boolean)
|
||||
fileCount.value = lines.length
|
||||
const records = parseDatasetRecordValues(text, file.name)
|
||||
fileCount.value = records.length
|
||||
|
||||
// Alpaca 格式校验:每行 JSON 须含 instruction 字段
|
||||
let validCount = 0
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const obj = JSON.parse(line)
|
||||
if (obj.instruction !== undefined) validCount++
|
||||
} catch {
|
||||
// 非 JSON 行(如纯 JSONL 多行结构)
|
||||
}
|
||||
}
|
||||
if (validCount > 0 && validCount === lines.length) {
|
||||
const validCount = records.filter(
|
||||
(obj) => obj && typeof obj === 'object' && 'instruction' in obj,
|
||||
).length
|
||||
if (validCount > 0 && validCount === records.length) {
|
||||
formatValid.value = true
|
||||
formatMessage.value = `符合 Alpaca 格式(含 instruction 字段)`
|
||||
} else if (validCount > 0) {
|
||||
formatValid.value = true
|
||||
formatMessage.value = `部分符合 Alpaca 格式(${validCount}/${lines.length})`
|
||||
formatMessage.value = `部分符合 Alpaca 格式(${validCount}/${records.length})`
|
||||
} else {
|
||||
formatValid.value = false
|
||||
formatMessage.value = '未检测到标准 Alpaca 格式(缺少 instruction 字段),仍可上传'
|
||||
|
||||
Reference in New Issue
Block a user