-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathsynthesis-api.ts
More file actions
89 lines (77 loc) · 3.6 KB
/
synthesis-api.ts
File metadata and controls
89 lines (77 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { get, post, del, patch } from "@/utils/request";
// 创建数据合成任务
export function createSynthesisTaskUsingPost(data: Record<string, unknown>) {
return post("/api/synthesis/gen/task", data as unknown as Record<string, never>);
}
// 获取数据合成任务详情
export function querySynthesisTaskByIdUsingGet(taskId: string) {
return get(`/api/synthesis/gen/task/${taskId}`);
}
// 分页查询数据合成任务列表
export function querySynthesisTasksUsingGet(params: {
page?: number;
page_size?: number;
synthesis_type?: string;
status?: string;
name?: string;
}) {
const searchParams = new URLSearchParams();
if (params.page !== undefined) searchParams.append("page", String(params.page));
if (params.page_size !== undefined) searchParams.append("page_size", String(params.page_size));
if (params.synthesis_type) searchParams.append("synthesis_type", params.synthesis_type);
if (params.status) searchParams.append("status", params.status);
if (params.name) searchParams.append("name", params.name);
const qs = searchParams.toString();
return get(`/api/synthesis/gen/tasks${qs ? `?${qs}` : ""}`);
}
// 删除整个数据合成任务
export function deleteSynthesisTaskByIdUsingDelete(taskId: string) {
return del(`/api/synthesis/gen/task/${taskId}`);
}
// 分页查询某个任务下的文件任务列表
export function querySynthesisFileTasksUsingGet(taskId: string, params: { page?: number; page_size?: number }) {
const searchParams = new URLSearchParams();
if (params.page !== undefined) searchParams.append("page", String(params.page));
if (params.page_size !== undefined) searchParams.append("page_size", String(params.page_size));
const qs = searchParams.toString();
return get(`/api/synthesis/gen/task/${taskId}/files${qs ? `?${qs}` : ""}`);
}
// 根据文件任务 ID 分页查询 chunk 记录
export function queryChunksByFileUsingGet(fileId: string, params: { page?: number; page_size?: number }) {
const searchParams = new URLSearchParams();
if (params.page !== undefined) searchParams.append("page", String(params.page));
if (params.page_size !== undefined) searchParams.append("page_size", String(params.page_size));
const qs = searchParams.toString();
return get(`/api/synthesis/gen/file/${fileId}/chunks${qs ? `?${qs}` : ""}`);
}
// 根据 chunk ID 查询所有合成结果数据
export function querySynthesisDataByChunkUsingGet(chunkId: string) {
return get(`/api/synthesis/gen/chunk/${chunkId}/data`);
}
// 获取不同合成类型对应的 Prompt
export function getPromptByTypeUsingGet(synthType: string) {
const searchParams = new URLSearchParams();
searchParams.append("synth_type", synthType);
const qs = searchParams.toString();
return get(`/api/synthesis/gen/prompt${qs ? `?${qs}` : ""}`);
}
// 将合成任务数据归档到已存在的数据集中
export function archiveSynthesisTaskToDatasetUsingPost(
taskId: string,
datasetId: string,
format: string = "alpaca"
) {
return post(`/api/synthesis/gen/task/${taskId}/export-dataset/${datasetId}?format=${format}`);
}
// 删除 chunk 及其关联的合成数据
export function deleteChunkWithDataUsingDelete(chunkId: string) {
return del(`/api/synthesis/gen/chunk/${chunkId}`);
}
// 批量删除合成数据
export function batchDeleteSynthesisDataUsingDelete(data: { ids: string[] }) {
return del("/api/synthesis/gen/data/batch", data as unknown as Record<string, never>);
}
// 更新合成数据
export function updateSynthesisDataUsingPatch(dataId: string, data: { data: Record<string, unknown> }) {
return patch(`/api/synthesis/gen/data/${dataId}`, data as unknown as Record<string, never>);
}