You've already forked DataMate
fix: fix the Data Evaluation Detail page (#154)
* fix: the Data Evaluation Detail Page should show the model used * fix: fix the time format displayed * fix: fix the Data Evaluation Detail page
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
// TypeScript
|
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Button, Form, Input, Select, message, Modal, Row, Col, Table, Space } from 'antd';
|
import { Button, Form, Input, Select, message, Modal, Row, Col, Table, Space } from 'antd';
|
||||||
import { EyeOutlined } from '@ant-design/icons';
|
import { EyeOutlined } from '@ant-design/icons';
|
||||||
@@ -9,6 +8,7 @@ import { ModelI } from "@/pages/SettingsPage/ModelAccess.tsx";
|
|||||||
import { createEvaluationTaskUsingPost } from "@/pages/DataEvaluation/evaluation.api.ts";
|
import { createEvaluationTaskUsingPost } from "@/pages/DataEvaluation/evaluation.api.ts";
|
||||||
import { queryPromptTemplatesUsingGet } from "@/pages/DataEvaluation/evaluation.api.ts";
|
import { queryPromptTemplatesUsingGet } from "@/pages/DataEvaluation/evaluation.api.ts";
|
||||||
import PreviewPromptModal from "@/pages/DataEvaluation/Create/PreviewPrompt.tsx";
|
import PreviewPromptModal from "@/pages/DataEvaluation/Create/PreviewPrompt.tsx";
|
||||||
|
import { EVAL_METHODS, TASK_TYPES } from "@/pages/DataEvaluation/evaluation.const.tsx";
|
||||||
|
|
||||||
interface Dataset {
|
interface Dataset {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -35,15 +35,6 @@ interface CreateTaskModalProps {
|
|||||||
onSuccess: () => void;
|
onSuccess: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TASK_TYPES = [
|
|
||||||
{ label: 'QA评估', value: 'QA' },
|
|
||||||
{ label: 'COT评估', value: 'COT' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const EVAL_METHODS = [
|
|
||||||
{ label: '模型自动评估', value: 'AUTO' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const DEFAULT_EVAL_METHOD = 'AUTO';
|
const DEFAULT_EVAL_METHOD = 'AUTO';
|
||||||
const DEFAULT_TASK_TYPE = 'QA';
|
const DEFAULT_TASK_TYPE = 'QA';
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Descriptions, Empty, DescriptionsProps, Table, Button, message } from 'antd';
|
import { Descriptions, Empty, DescriptionsProps, Table, Button } from 'antd';
|
||||||
import { CheckCircle, XCircle, Clock as ClockIcon } from 'lucide-react';
|
|
||||||
import { EyeOutlined } from '@ant-design/icons';
|
import { EyeOutlined } from '@ant-design/icons';
|
||||||
import { EvaluationStatus } from '../../evaluation.model';
|
|
||||||
import PreviewPromptModal from "@/pages/DataEvaluation/Create/PreviewPrompt.tsx";
|
import PreviewPromptModal from "@/pages/DataEvaluation/Create/PreviewPrompt.tsx";
|
||||||
|
import { formatDateTime } from "@/utils/unit.ts";
|
||||||
const statusMap = {
|
import { evalTaskStatusMap, getEvalMethod, getEvalType, getSource } from "@/pages/DataEvaluation/evaluation.const.tsx";
|
||||||
[EvaluationStatus.PENDING]: { color: 'blue', text: '待处理', icon: <ClockIcon className="mr-1" size={14} /> },
|
|
||||||
[EvaluationStatus.RUNNING]: { color: 'processing', text: '进行中', icon: <ClockIcon className="mr-1" size={14} /> },
|
|
||||||
[EvaluationStatus.COMPLETED]: { color: 'success', text: '已完成', icon: <CheckCircle className="mr-1" size={14} /> },
|
|
||||||
[EvaluationStatus.FAILED]: { color: 'error', text: '失败', icon: <XCircle className="mr-1" size={14} /> },
|
|
||||||
[EvaluationStatus.PAUSED]: { color: 'warning', text: '已暂停', icon: <ClockIcon className="mr-1" size={14} /> },
|
|
||||||
};
|
|
||||||
|
|
||||||
const Overview = ({ task }) => {
|
const Overview = ({ task }) => {
|
||||||
const [previewVisible, setPreviewVisible] = useState(false);
|
const [previewVisible, setPreviewVisible] = useState(false);
|
||||||
@@ -23,8 +15,6 @@ const Overview = ({ task }) => {
|
|||||||
setPreviewVisible(true);
|
setPreviewVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const statusInfo = statusMap[task.status] || { color: 'default', text: '未知状态' };
|
|
||||||
|
|
||||||
// 基本信息
|
// 基本信息
|
||||||
const items: DescriptionsProps["items"] = [
|
const items: DescriptionsProps["items"] = [
|
||||||
{
|
{
|
||||||
@@ -37,10 +27,30 @@ const Overview = ({ task }) => {
|
|||||||
label: "名称",
|
label: "名称",
|
||||||
children: task.name,
|
children: task.name,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "evalType",
|
||||||
|
label: "评估类型",
|
||||||
|
children: getEvalType(task.taskType),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "evalMethod",
|
||||||
|
label: "评估方式",
|
||||||
|
children: getEvalMethod(task.evalMethod),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "status",
|
key: "status",
|
||||||
label: "状态",
|
label: "状态",
|
||||||
children: statusInfo.text || "未知",
|
children: evalTaskStatusMap[task.status]?.label || "未知",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "source",
|
||||||
|
label: "评估数据",
|
||||||
|
children: getSource(task.sourceType) + task.sourceName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "evalConfig.modelName",
|
||||||
|
label: "模型",
|
||||||
|
children: task.evalConfig?.modelName || task.evalConfig?.modelId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "createdBy",
|
key: "createdBy",
|
||||||
@@ -50,12 +60,12 @@ const Overview = ({ task }) => {
|
|||||||
{
|
{
|
||||||
key: "createdAt",
|
key: "createdAt",
|
||||||
label: "创建时间",
|
label: "创建时间",
|
||||||
children: task.createdAt,
|
children: formatDateTime(task.createdAt),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "updatedAt",
|
key: "updatedAt",
|
||||||
label: "更新时间",
|
label: "更新时间",
|
||||||
children: task.updatedAt,
|
children: formatDateTime(task.updatedAt),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "description",
|
key: "description",
|
||||||
|
|||||||
@@ -1,7 +1,35 @@
|
|||||||
import { formatDate } from "@/utils/unit";
|
import { formatDateTime } from "@/utils/unit";
|
||||||
import { BarChart3 } from "lucide-react";
|
import { BarChart3 } from "lucide-react";
|
||||||
import { EvaluationStatus, EvaluationTask } from "@/pages/DataEvaluation/evaluation.model.ts";
|
import { EvaluationStatus, EvaluationTask } from "@/pages/DataEvaluation/evaluation.model.ts";
|
||||||
|
|
||||||
|
export const TASK_TYPES = [
|
||||||
|
{ label: 'QA评估', value: 'QA' },
|
||||||
|
{ label: 'COT评估', value: 'COT' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const EVAL_METHODS = [
|
||||||
|
{ label: '模型自动评估', value: 'AUTO' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEvalType = (type: string) => {
|
||||||
|
return TASK_TYPES.find((item) => item.value === type)?.label;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEvalMethod = (type: string) => {
|
||||||
|
return EVAL_METHODS.find((item) => item.value === type)?.label;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getSource = (type: string) => {
|
||||||
|
switch (type) {
|
||||||
|
case "DATASET":
|
||||||
|
return "数据集 - ";
|
||||||
|
case "SYNTHESIS":
|
||||||
|
return "合成任务 - ";
|
||||||
|
default:
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const evalTaskStatusMap: Record<
|
export const evalTaskStatusMap: Record<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
@@ -41,8 +69,8 @@ export function mapEvaluationTask(task: Partial<EvaluationTask>): EvaluationTask
|
|||||||
return {
|
return {
|
||||||
...task,
|
...task,
|
||||||
status: evalTaskStatusMap[task.status || EvaluationStatus.PENDING],
|
status: evalTaskStatusMap[task.status || EvaluationStatus.PENDING],
|
||||||
createdAt: formatDate(task.createdAt),
|
createdAt: formatDateTime(task.createdAt),
|
||||||
updatedAt: formatDate(task.updatedAt),
|
updatedAt: formatDateTime(task.updatedAt),
|
||||||
description: task.description,
|
description: task.description,
|
||||||
icon: <BarChart3 />,
|
icon: <BarChart3 />,
|
||||||
iconColor: task.ratio_method === "DATASET" ? "bg-blue-100" : "bg-green-100",
|
iconColor: task.ratio_method === "DATASET" ? "bg-blue-100" : "bg-green-100",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { formatDate } from "@/utils/unit";
|
import { formatDateTime } from "@/utils/unit";
|
||||||
import { RatioTaskItem, RatioStatus } from "./ratio.model";
|
import { RatioTaskItem, RatioStatus } from "./ratio.model";
|
||||||
import { BarChart3, Calendar, Database } from "lucide-react";
|
import { BarChart3, Calendar, Database } from "lucide-react";
|
||||||
import { Link } from "react-router";
|
import { Link } from "react-router";
|
||||||
@@ -43,8 +43,8 @@ export function mapRatioTask(task: Partial<RatioTaskItem>): RatioTaskItem {
|
|||||||
return {
|
return {
|
||||||
...task,
|
...task,
|
||||||
status: ratioTaskStatusMap[task.status || RatioStatus.PENDING],
|
status: ratioTaskStatusMap[task.status || RatioStatus.PENDING],
|
||||||
createdAt: formatDate(task.created_at),
|
createdAt: formatDateTime(task.created_at),
|
||||||
updatedAt: formatDate(task.updated_at),
|
updatedAt: formatDateTime(task.updated_at),
|
||||||
description: task.description,
|
description: task.description,
|
||||||
icon: <BarChart3 />,
|
icon: <BarChart3 />,
|
||||||
iconColor: task.ratio_method === "DATASET" ? "bg-blue-100" : "bg-green-100",
|
iconColor: task.ratio_method === "DATASET" ? "bg-blue-100" : "bg-green-100",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ from app.module.evaluation.schema.prompt_template import PromptTemplateResponse
|
|||||||
from app.module.evaluation.service.prompt_template_service import PromptTemplateService
|
from app.module.evaluation.service.prompt_template_service import PromptTemplateService
|
||||||
from app.module.evaluation.service.evaluation import EvaluationTaskService
|
from app.module.evaluation.service.evaluation import EvaluationTaskService
|
||||||
from app.module.shared.schema.common import StandardResponse, TaskStatus
|
from app.module.shared.schema.common import StandardResponse, TaskStatus
|
||||||
|
from app.module.system.service.common_service import get_model_by_id
|
||||||
|
|
||||||
router = APIRouter(
|
router = APIRouter(
|
||||||
prefix="",
|
prefix="",
|
||||||
@@ -79,6 +80,10 @@ async def create_evaluation_task(
|
|||||||
if existing_task.scalar_one_or_none():
|
if existing_task.scalar_one_or_none():
|
||||||
raise HTTPException(status_code=400, detail=f"Evaluation task with name '{request.name}' already exists")
|
raise HTTPException(status_code=400, detail=f"Evaluation task with name '{request.name}' already exists")
|
||||||
|
|
||||||
|
model_config = await get_model_by_id(db, request.eval_config.model_id)
|
||||||
|
if not model_config:
|
||||||
|
raise HTTPException(status_code=400, detail=f"Model with id '{request.eval_config.model_id}' not found")
|
||||||
|
|
||||||
# 创建评估任务
|
# 创建评估任务
|
||||||
task = EvaluationTask(
|
task = EvaluationTask(
|
||||||
id=str(uuid.uuid4()),
|
id=str(uuid.uuid4()),
|
||||||
@@ -90,7 +95,8 @@ async def create_evaluation_task(
|
|||||||
source_name=request.source_name,
|
source_name=request.source_name,
|
||||||
eval_prompt=request.eval_prompt,
|
eval_prompt=request.eval_prompt,
|
||||||
eval_config=json.dumps({
|
eval_config=json.dumps({
|
||||||
"model_id": request.eval_config.model_id,
|
"modelId": request.eval_config.model_id,
|
||||||
|
"modelName": model_config.model_name,
|
||||||
"dimensions": request.eval_config.dimensions,
|
"dimensions": request.eval_config.dimensions,
|
||||||
}),
|
}),
|
||||||
status=TaskStatus.PENDING.value,
|
status=TaskStatus.PENDING.value,
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class EvaluationExecutor:
|
|||||||
|
|
||||||
async def execute(self):
|
async def execute(self):
|
||||||
eval_config = json.loads(self.task.eval_config)
|
eval_config = json.loads(self.task.eval_config)
|
||||||
model_config = await get_model_by_id(self.db, eval_config.get("model_id"))
|
model_config = await get_model_by_id(self.db, eval_config.get("modelId"))
|
||||||
semaphore = asyncio.Semaphore(10)
|
semaphore = asyncio.Semaphore(10)
|
||||||
files = (await self.db.execute(
|
files = (await self.db.execute(
|
||||||
select(EvaluationFile).where(EvaluationFile.task_id == self.task.id)
|
select(EvaluationFile).where(EvaluationFile.task_id == self.task.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user