222 lines
4.6 KiB
TypeScript
222 lines
4.6 KiB
TypeScript
import request from '/@/utils/request';
|
||
|
||
/** Token 映射(三个字段存的是对应响应映射中的 key,不是 JSON Path) */
|
||
export interface TokenMapping {
|
||
promptTokens: string;
|
||
completionTokens: string;
|
||
totalTokens: string;
|
||
}
|
||
|
||
/** 异步任务映射 */
|
||
export interface AsyncTaskMapping {
|
||
url: string;
|
||
httpMethod: string;
|
||
requestHeadMapping: Record<string, unknown>;
|
||
responseMapping: Record<string, unknown>;
|
||
taskId: string;
|
||
taskStatus: string;
|
||
taskStatusPending: string;
|
||
taskStatusRunning: string;
|
||
taskStatusSuccess: string;
|
||
taskStatusFailed: string;
|
||
taskStatusCancel: string;
|
||
taskStatusUnknown: string;
|
||
}
|
||
|
||
/** 列表查询参数 */
|
||
export interface ListModelManageParams {
|
||
pageNum: number;
|
||
pageSize: number;
|
||
modelName?: string;
|
||
modelType?: number;
|
||
}
|
||
|
||
/** 列表项 */
|
||
export interface ModelManageItem {
|
||
id: string;
|
||
tenantId: number;
|
||
creator: string;
|
||
createdAt: string;
|
||
updater: string;
|
||
updatedAt: string;
|
||
deletedAt: null | string;
|
||
modelSupplier: string;
|
||
modelName: string;
|
||
modelType: number;
|
||
baseUrl: string;
|
||
responseType: number;
|
||
apiKey: string;
|
||
enabled: boolean;
|
||
ChatModel: boolean;
|
||
maxConcurrency: number;
|
||
maxTokens: number;
|
||
tokenPredictPrice: number;
|
||
requestHeadMapping: Record<string, unknown>;
|
||
requestBodyMapping: Record<string, unknown>;
|
||
responseMapping: Record<string, unknown>;
|
||
responseBodyMapping: Record<string, string>;
|
||
tokenMapping?: TokenMapping;
|
||
asyncTaskMapping?: AsyncTaskMapping;
|
||
lastFrame?: string;
|
||
maxDuration: number;
|
||
tokenPredictPriceUnit: string;
|
||
// 以下旧字段兼容
|
||
httpMethod?: string;
|
||
systemModel?: boolean;
|
||
PrivateModel?: boolean;
|
||
invokeType?: number;
|
||
requestMapping?: Record<string, unknown>;
|
||
}
|
||
|
||
/** 列表响应 */
|
||
export interface ListModelManageResponse {
|
||
code: number;
|
||
message: string;
|
||
data: {
|
||
list: ModelManageItem[];
|
||
total: number;
|
||
};
|
||
}
|
||
|
||
/** 模型类型树节点(支持二级) */
|
||
export interface ModelTypeTreeNode {
|
||
value: number;
|
||
label: string;
|
||
children?: ModelTypeTreeNode[];
|
||
}
|
||
|
||
/** 模型类型列表响应 */
|
||
export interface ModelManageTypeResponse {
|
||
code: number;
|
||
message: string;
|
||
data: {
|
||
list: ModelTypeTreeNode[];
|
||
};
|
||
}
|
||
|
||
/** 供应商列表项 */
|
||
export interface ModelSupplierItem {
|
||
value: number;
|
||
label: string;
|
||
}
|
||
|
||
/** 供应商列表响应 */
|
||
export interface ModelSupplierListResponse {
|
||
code: number;
|
||
message: string;
|
||
data: {
|
||
list: ModelSupplierItem[];
|
||
};
|
||
}
|
||
|
||
/**
|
||
* 获取模型配置列表(v2)
|
||
*/
|
||
export function listModelManage(params: ListModelManageParams) {
|
||
return request({
|
||
url: '/model-gateway/model/manage/listModelManage',
|
||
method: 'get',
|
||
params,
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 获取模型类型列表(v2,树形结构,支持一级/二级)
|
||
*/
|
||
export function getModelManageTypes() {
|
||
return request({
|
||
url: '/model-gateway/model/manage/modelType',
|
||
method: 'get',
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 删除模型配置
|
||
*/
|
||
export function deleteModelManage(id: string) {
|
||
return request({
|
||
url: '/model-gateway/model/manage/deleteModelManage',
|
||
method: 'delete',
|
||
data: { id },
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 获取模型供应商列表
|
||
*/
|
||
export function getModelSupplierList() {
|
||
return request({
|
||
url: '/model-gateway/model/manage/modelSupplier',
|
||
method: 'get',
|
||
});
|
||
}
|
||
|
||
/** 创建模型配置参数 */
|
||
export interface CreateModelManageParams {
|
||
modelSupplier: number;
|
||
modelName: string;
|
||
modelType: number;
|
||
baseUrl: string;
|
||
responseType: number;
|
||
apiKey?: string;
|
||
enabled?: boolean;
|
||
chatModel?: boolean;
|
||
maxConcurrency?: number;
|
||
maxTokens?: number;
|
||
tokenPredictPrice?: number;
|
||
requestHeadMapping?: Record<string, unknown>;
|
||
requestBodyMapping?: Record<string, unknown>;
|
||
responseMapping?: Record<string, unknown>;
|
||
responseBodyMapping?: Record<string, string>;
|
||
tokenMapping?: TokenMapping;
|
||
asyncTaskMapping?: AsyncTaskMapping;
|
||
lastFrame?: string;
|
||
maxDuration?: number;
|
||
tokenPredictPriceUnit?: string;
|
||
}
|
||
|
||
/** 更新模型配置参数 */
|
||
export interface UpdateModelManageParams extends Partial<CreateModelManageParams> {
|
||
id: string;
|
||
}
|
||
|
||
/** 详情响应 */
|
||
export interface ModelManageDetailResponse {
|
||
code: number;
|
||
message: string;
|
||
data: ModelManageItem;
|
||
}
|
||
|
||
/**
|
||
* 获取模型配置详情
|
||
*/
|
||
export function getModelManage(id: string) {
|
||
return request({
|
||
url: '/model-gateway/model/manage/getModelManage',
|
||
method: 'get',
|
||
params: { id },
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 创建模型配置
|
||
*/
|
||
export function createModelManage(data: CreateModelManageParams) {
|
||
return request({
|
||
url: '/model-gateway/model/manage/createModelManage',
|
||
method: 'post',
|
||
data,
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 更新模型配置
|
||
*/
|
||
export function updateModelManage(data: UpdateModelManageParams) {
|
||
return request({
|
||
url: '/model-gateway/model/manage/updateModelManage',
|
||
method: 'put',
|
||
data,
|
||
});
|
||
}
|