forked from labring/aiproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.ts
More file actions
52 lines (45 loc) · 1.23 KB
/
model.ts
File metadata and controls
52 lines (45 loc) · 1.23 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
// src/api/model.ts
import { get, post, del } from "./index";
import { ModelConfig, ModelCreateRequest } from "@/types/model";
// Define the type for model sets response
export interface ModelSetsResponse {
[modelName: string]: {
[setName: string]: Array<{
id: number;
type: number;
name: string;
}>;
};
}
export const modelApi = {
getModels: async (): Promise<ModelConfig[]> => {
const response = await get<ModelConfig[]>("model_configs/all");
return response;
},
getModel: async (model: string): Promise<ModelConfig> => {
const response = await get<ModelConfig>(`model_config/${model}`);
return response;
},
getModelSets: async () => {
const response = await get<ModelSetsResponse>("models/sets");
return response;
},
createModel: async (
model: string,
data: Omit<ModelCreateRequest, "model">
): Promise<void> => {
await post(`model_config/${model}`, data);
return;
},
updateModel: async (
model: string,
data: Omit<ModelCreateRequest, "model">
): Promise<void> => {
await post(`model_config/${model}`, data);
return;
},
deleteModel: async (model: string): Promise<void> => {
await del(`model_config/${model}`);
return;
},
};