142 lines
3.5 KiB
TypeScript
142 lines
3.5 KiB
TypeScript
import { get, post } from './request';
|
|
|
|
export interface ModelProvider {
|
|
id?: string;
|
|
providerCode: string;
|
|
providerName: string;
|
|
providerType: string;
|
|
protocolType: string;
|
|
baseUrl: string;
|
|
authType: string;
|
|
secretRef?: string;
|
|
hasApiKey?: boolean;
|
|
timeoutMs: number;
|
|
priority: number;
|
|
enabled: boolean;
|
|
healthStatus?: string;
|
|
remark?: string;
|
|
}
|
|
|
|
export interface ModelConfig {
|
|
id?: string;
|
|
providerId: string;
|
|
modelCode: string;
|
|
modelName: string;
|
|
upstreamModel: string;
|
|
modelType: string;
|
|
embeddingDimension?: number;
|
|
localModel: boolean;
|
|
defaultModel: boolean;
|
|
optionsJson?: string;
|
|
enabled: boolean;
|
|
remark?: string;
|
|
}
|
|
|
|
export interface ModelRouteRule {
|
|
id?: string;
|
|
routeCode: string;
|
|
routeName: string;
|
|
taskType: string;
|
|
matchScope: string;
|
|
scopeId?: string;
|
|
primaryModelId: string;
|
|
fallbackModelIdsJson?: string;
|
|
routeStrategy: string;
|
|
maxLatencyMs?: number;
|
|
enabled: boolean;
|
|
remark?: string;
|
|
}
|
|
|
|
export interface ModelCallLog {
|
|
id?: string;
|
|
requestId: string;
|
|
providerId?: string;
|
|
modelId?: string;
|
|
taskType: string;
|
|
bizType?: string;
|
|
bizId?: string;
|
|
callType: string;
|
|
status: string;
|
|
durationMs?: number;
|
|
errorCode?: string;
|
|
errorMessage?: string;
|
|
}
|
|
|
|
export interface ModelCallLogQueryRequest {
|
|
taskType?: string;
|
|
providerId?: string;
|
|
modelId?: string;
|
|
status?: string;
|
|
bizType?: string;
|
|
}
|
|
|
|
export interface RagStoreModelConfig {
|
|
id?: string;
|
|
storeId: string;
|
|
embeddingModelId: string;
|
|
embeddingDimension: number;
|
|
chunkStrategy?: number;
|
|
chunkSize?: number;
|
|
chunkOverlap?: number;
|
|
delimiter?: string;
|
|
active?: boolean;
|
|
indexVersion?: number;
|
|
remark?: string;
|
|
}
|
|
|
|
export function queryModelProviders() {
|
|
return post<ModelProvider[]>('/model/providers/query');
|
|
}
|
|
|
|
export function saveModelProvider(data: Partial<ModelProvider> & { id?: string }) {
|
|
return post<boolean>('/model/providers/save', data);
|
|
}
|
|
|
|
export function deleteModelProvider(id: string) {
|
|
return post<boolean>('/model/providers/delete', undefined, { params: { id } });
|
|
}
|
|
|
|
export function checkModelProviderHealth(id: string) {
|
|
return post<boolean>('/model/providers/checkHealth', undefined, { params: { id } });
|
|
}
|
|
|
|
export function queryModelConfigs() {
|
|
return post<ModelConfig[]>('/model/configs/query');
|
|
}
|
|
|
|
export function saveModelConfig(data: Partial<ModelConfig> & { id?: string }) {
|
|
return post<boolean>('/model/configs/save', data);
|
|
}
|
|
|
|
export function deleteModelConfig(id: string) {
|
|
return post<boolean>('/model/configs/delete', undefined, { params: { id } });
|
|
}
|
|
|
|
export function queryModelRouteRules() {
|
|
return post<ModelRouteRule[]>('/model/routes/query');
|
|
}
|
|
|
|
export function saveModelRouteRule(data: Partial<ModelRouteRule> & { id?: string }) {
|
|
return post<boolean>('/model/routes/save', data);
|
|
}
|
|
|
|
export function deleteModelRouteRule(id: string) {
|
|
return post<boolean>('/model/routes/delete', undefined, { params: { id } });
|
|
}
|
|
|
|
export function queryModelCallLogs(query?: ModelCallLogQueryRequest) {
|
|
return post<ModelCallLog[], ModelCallLogQueryRequest | undefined>('/model/call-logs/query', query);
|
|
}
|
|
|
|
export function getRagStoreModelConfig(storeId: string) {
|
|
return get<RagStoreModelConfig>('/rag/store/modelConfig', { params: { storeId } });
|
|
}
|
|
|
|
export function saveRagStoreModelConfig(data: Partial<RagStoreModelConfig> & { storeId: string }) {
|
|
return post<boolean>('/rag/store/modelConfig/save', data);
|
|
}
|
|
|
|
export function rebuildRagStoreIndex(storeId: string) {
|
|
return post<boolean>('/rag/store/rebuildIndex', undefined, { params: { storeId } });
|
|
}
|