Skip to content

Commit acafe70

Browse files
authored
feat: add ModelAccess to settings page (#29)
* feat: Update site name to DataMate and refine text for AI data processing * feat: Refactor settings page and implement model access functionality - Created a new ModelAccess component for managing model configurations. - Removed the old Settings component and replaced it with a new SettingsPage component that integrates ModelAccess, SystemConfig, and WebhookConfig. - Added SystemConfig component for managing system settings. - Implemented WebhookConfig component for managing webhook configurations. - Updated API functions for model management in settings.apis.ts. - Adjusted routing to point to the new SettingsPage component.
1 parent a4b5238 commit acafe70

File tree

14 files changed

+662
-444
lines changed

14 files changed

+662
-444
lines changed

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/huawei-logo.webp" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>ML Dataset Tool</title>
7+
<title>DataMate</title>
88
</head>
99
<body>
1010
<div id="root"></div>

frontend/src/mock/mock-apis.cjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ const { addMockPrefix } = require("./mock-core/util.cjs");
22

33
const MockAPI = {
44
// 数据归集接口
5-
queryTasksUsingPost: "/data-collection/tasks", // 获取数据源任务列表
5+
queryTasksUsingGet: "/data-collection/tasks", // 获取数据源任务列表
66
createTaskUsingPost: "/data-collection/tasks/create", // 创建数据源任务
77
queryTaskByIdUsingGet: "/data-collection/tasks/:id", // 根据ID获取数据源任务详情
88
updateTaskByIdUsingPut: "/data-collection/tasks/:id", // 更新数据源任务
9+
queryDataXTemplatesUsingGet: "/data-collection/templates", // 获取DataX数据源模板列表
910
deleteTaskByIdUsingDelete: "/data-collection/tasks/:id", // 删除数据源任务
1011
executeTaskByIdUsingPost: "/data-collection/tasks/:id/execute", // 执行数据源任务
1112
stopTaskByIdUsingPost: "/data-collection/tasks/:id/stop", // 停止数据源任务
@@ -91,7 +92,6 @@ const MockAPI = {
9192
deleteInstructionTemplateByIdUsingDelete: "/synthesis/templates/:templateId", // 删除指令模板
9293
instructionTuningUsingPost: "/synthesis/instruction-tuning", // 指令微调
9394
cotDistillationUsingPost: "/synthesis/cot-distillation", // Cot蒸馏
94-
queryOperatorsUsingPost: "/synthesis/operators", // 获取操作列表
9595

9696
// 数据评测接口
9797
queryEvaluationTasksUsingPost: "/evaluation/tasks", // 获取评测任务列表
@@ -144,6 +144,14 @@ const MockAPI = {
144144
deleteOperatorByIdUsingDelete: "/operators/:operatorId", // 删除算子
145145
publishOperatorUsingPost: "/operators/:operatorId/publish", // 发布算子
146146
unpublishOperatorUsingPost: "/operators/:operatorId/unpublish", // 下架算子
147+
148+
// 设置接口
149+
queryModelsUsingGet: "/models/list", // 获取模型列表
150+
queryProvidersUsingGet: "/models/providers", // 获取模型提供商列表
151+
createModelUsingPost: "/models/create", // 创建模型
152+
updateModelUsingPut: "/models/:id", // 更新模型
153+
deleteModelUsingDelete: "/models/:id", // 删除模型
154+
147155
};
148156

149157
module.exports = addMockPrefix("/api", MockAPI);

frontend/src/mock/mock-seed/data-management.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function datasetItem() {
1616
return {
1717
id: Mock.Random.guid().replace(/[^a-zA-Z0-9]/g, ""),
1818
name: Mock.Random.ctitle(5, 20),
19-
type: Mock.Random.pick(["TEXT", "IMAGE", "AUDIO", "VIDEO"]),
20-
status: Mock.Random.pick(["ACTIVE", "INACTIVE", "PROCESSING"]),
19+
datasetType: Mock.Random.pick(["TEXT", "IMAGE", "AUDIO", "VIDEO"]),
20+
status: Mock.Random.pick(["DRAFT","ACTIVE", "INACTIVE", "PROCESSING"]),
2121
tags: Mock.Random.shuffle(tagList).slice(0, Mock.Random.integer(1, 3)),
2222
totalSize: Mock.Random.integer(1024, 1024 * 1024 * 1024), // in bytes
2323
description: Mock.Random.cparagraph(1, 3),
@@ -164,7 +164,7 @@ module.exports = function (router) {
164164
console.log("filter type:", type);
165165

166166
filteredDatasets = filteredDatasets.filter(
167-
(dataset) => dataset.type === type
167+
(dataset) => dataset.datasetType === type
168168
);
169169
}
170170
if (status) {
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
const Mock = require("mockjs");
2+
const API = require("../mock-apis.cjs");
3+
4+
// 算子标签数据
5+
function ModelItem() {
6+
return {
7+
id: Mock.Random.guid().replace(/[^a-zA-Z0-9]/g, ""),
8+
modelName: Mock.Random.pick([
9+
"数据清洗",
10+
"特征选择",
11+
"分类算法",
12+
"聚类算法",
13+
"回归分析",
14+
"深度神经网络",
15+
"卷积神经网络",
16+
"循环神经网络",
17+
"注意力机制",
18+
"文本分析",
19+
"图像处理",
20+
"语音识别",
21+
"推荐算法",
22+
"异常检测",
23+
"优化算法",
24+
"集成学习",
25+
"迁移学习",
26+
"强化学习",
27+
"联邦学习",
28+
]),
29+
provider: Mock.Random.pick([
30+
"OpenAI",
31+
"Anthropic",
32+
"Cohere",
33+
"AI21 Labs",
34+
"Hugging Face",
35+
"Google Cloud AI",
36+
"Microsoft Azure AI",
37+
"Amazon Web Services AI",
38+
"IBM Watson",
39+
"Alibaba Cloud AI",
40+
]),
41+
type: Mock.Random.pick(["CHAT", "EMBEDDING"]),
42+
usageCount: Mock.Random.integer(1, 500),
43+
createdAt: Mock.Random.datetime("yyyy-MM-dd HH:mm:ss"),
44+
updatedAt: Mock.Random.datetime("yyyy-MM-dd HH:mm:ss"),
45+
};
46+
}
47+
48+
const modelList = new Array(50).fill(null).map(ModelItem);
49+
50+
function ProviderItem(provider) {
51+
return {
52+
id: Mock.Random.guid().replace(/[^a-zA-Z0-9]/g, ""),
53+
provider,
54+
baseUrl: Mock.Random.url("https") + "/v1/models",
55+
createdAt: Mock.Random.datetime("yyyy-MM-dd HH:mm:ss"),
56+
};
57+
}
58+
59+
const ProviderList = [
60+
"OpenAI",
61+
"Anthropic",
62+
"Cohere",
63+
"AI21 Labs",
64+
"Hugging Face",
65+
"Google Cloud AI",
66+
"Microsoft Azure AI",
67+
"Amazon Web Services AI",
68+
"IBM Watson",
69+
"Alibaba Cloud AI",
70+
].map(ProviderItem);
71+
72+
module.exports = function (router) {
73+
// 获取模型列表
74+
router.get(API.queryModelsUsingGet, (req, res) => {
75+
const {
76+
page = 0,
77+
size = 20,
78+
keyword = "",
79+
provider = "",
80+
type = "",
81+
} = req.query;
82+
83+
let filteredModels = modelList;
84+
85+
if (keyword) {
86+
filteredModels = modelList.filter((model) =>
87+
model.modelName.toLowerCase().includes(keyword.toLowerCase())
88+
);
89+
}
90+
if (provider && provider !== "all") {
91+
filteredModels = filteredModels.filter(
92+
(model) => model.provider === provider
93+
);
94+
}
95+
if (type && type !== "all") {
96+
filteredModels = filteredModels.filter((model) => model.type === type);
97+
}
98+
99+
const startIndex = page * size;
100+
const endIndex = startIndex + parseInt(size);
101+
const pageData = filteredModels.slice(startIndex, endIndex);
102+
103+
res.status(201).send({
104+
code: "0",
105+
msg: "Success",
106+
data: {
107+
content: pageData,
108+
totalElements: filteredModels.length,
109+
totalPages: Math.ceil(filteredModels.length / size),
110+
size: parseInt(size),
111+
number: parseInt(page),
112+
},
113+
});
114+
});
115+
116+
// 获取模型提供商列表
117+
router.get(API.queryProvidersUsingGet, (req, res) => {
118+
res.status(201).send({
119+
code: "0",
120+
msg: "success",
121+
data: ProviderList,
122+
});
123+
});
124+
125+
// 创建模型
126+
router.post(API.createModelUsingPost, (req, res) => {
127+
const { ...modelData } = req.body;
128+
const newModel = {
129+
id: Mock.Random.guid().replace(/[^a-zA-Z0-9]/g, ""),
130+
...modelData,
131+
createdAt: new Date().toISOString(),
132+
updatedAt: new Date().toISOString(),
133+
};
134+
modelList.unshift(newModel);
135+
res.status(201).send({
136+
code: "0",
137+
msg: "success",
138+
data: newModel,
139+
});
140+
});
141+
142+
// 删除模型
143+
router.delete(API.deleteModelUsingDelete, (req, res) => {
144+
const { id } = req.params;
145+
146+
const index = modelList.findIndex((model) => model.id === id);
147+
if (index !== -1) {
148+
modelList.splice(index, 1);
149+
}
150+
151+
res.status(204).send({
152+
code: "0",
153+
msg: "success",
154+
data: null,
155+
});
156+
});
157+
158+
// 更新模型
159+
router.put(API.updateModelUsingPut, (req, res) => {
160+
const { id, ...update } = req.params;
161+
162+
const index = modelList.findIndex((model) => model.id === id);
163+
if (index !== -1) {
164+
modelList[index] = {
165+
...modelList[index],
166+
...update,
167+
updatedAt: new Date().toISOString(),
168+
};
169+
}
170+
171+
res.status(201).send({
172+
code: "0",
173+
msg: "success",
174+
data: null,
175+
});
176+
});
177+
};

frontend/src/pages/DataManagement/Home/DataManagement.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export default function DatasetManagementPage() {
5151
},
5252
{
5353
title: "文件总数",
54-
value: data?.totalFiles || "0 MB",
54+
value: data?.totalFiles || 0,
5555
},
5656
{
5757
title: "总大小",
58-
value: formatBytes(data?.totalSize) || 0,
58+
value: formatBytes(data?.totalSize) || '0 B',
5959
},
6060
],
6161
count: [

frontend/src/pages/Home/Home.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export default function WelcomePage() {
2929
<span className="text-blue-600"> AI数据集</span>
3030
</h1>
3131
<p className="text-xl text-gray-600 max-w-3xl mx-auto mb-8">
32-
从数据管理到知识生成,一站式解决机器学习数据准备的所有需求。
33-
支持对话式操作、智能编排、数据合成、智能标注、全面评估和RAG知识库构建。
32+
从数据管理到知识生成,一站式解决企业AI数据处理的场景问题。
3433
</p>
3534
<div className="flex flex-col sm:flex-row gap-4 justify-center">
3635
<span

0 commit comments

Comments
 (0)