refactor(core): 模型路由与画布 - 收敛渠道模型映射并优化交互

This commit is contained in:
ddCat
2026-08-19 20:27:26 +08:00
parent 52424543ea
commit d47975f9bc
34 changed files with 601 additions and 901 deletions

View File

@@ -39,12 +39,10 @@ export type PublicLogicalModel = {
export type AdminLogicalRoute = {
id: string;
physicalVariantId: string;
physicalVariantName: string;
channelModelId: string;
channelId: string;
physicalModelKey: string;
physicalModelName: string;
channelModelKey: string;
channelModelName: string;
enabled: boolean;
priority: number;
weight: number;
@@ -61,29 +59,6 @@ export type AdminLogicalModel = PublicLogicalModel & {
routes: AdminLogicalRoute[];
};
export type AdminPhysicalVariant = {
id: string;
channelModelId: string;
channelId: string;
modelKey: string;
modelName: string;
name: string;
capability: CapabilitySpec["capability"];
protocol: string;
enabled: boolean;
modelEnabled: boolean;
usageCount: number;
capabilitySpec: CapabilitySpec;
};
export type PhysicalVariantMutation = {
channelModelId: string;
name: string;
enabled: boolean;
/** 能力范围由渠道模型能力参数自动生成;保留可选字段兼容旧调用方。 */
capabilitySpec?: CapabilitySpec;
};
export type LogicalModelMutation = {
code: string;
name: string;
@@ -100,12 +75,12 @@ export type LogicalModelMutation = {
cachedPriceMicrocredits: number;
capabilitySpec: CapabilitySpec;
defaultOptions: Record<string, unknown>;
routes: Array<{ physicalVariantId: string; enabled: boolean; priority: number; weight: number }>;
routes: Array<{ channelModelId: string; enabled: boolean; priority: number; weight: number }>;
};
export type RouteSimulationResult = {
productMatch: { matched: boolean; reasons?: string[] };
candidates: Array<{ routeId: string; variantId: string; channelModelId: string; priority: number; weight: number; enabled: boolean; matched: boolean; blocked: boolean; inPool: boolean; reasons?: string[] }>;
candidates: Array<{ routeId: string; channelModelId: string; channelModelKey: string; channelModelName: string; priority: number; weight: number; enabled: boolean; matched: boolean; blocked: boolean; inPool: boolean; reasons?: string[] }>;
};
export function listLogicalModels() {
@@ -128,18 +103,6 @@ export function updateAdminLogicalModel(id: string, input: LogicalModelMutation)
return request<{ model: AdminLogicalModel }>(apiClient.patch(`/admin/logical-models/${encodeURIComponent(id)}`, input));
}
export function listAdminPhysicalVariants(channelModelId?: string) {
return request<{ variants: AdminPhysicalVariant[] }>(apiClient.get("/admin/logical-models/physical-variants", { params: channelModelId ? { channelModelId } : undefined }));
}
export function createAdminPhysicalVariant(input: PhysicalVariantMutation) {
return request<{ variant: AdminPhysicalVariant }>(apiClient.post("/admin/logical-models/physical-variants", input));
}
export function updateAdminPhysicalVariant(id: string, input: PhysicalVariantMutation) {
return request<{ variant: AdminPhysicalVariant }>(apiClient.patch(`/admin/logical-models/physical-variants/${encodeURIComponent(id)}`, input));
}
export function simulateAdminLogicalModel(id: string, intent: ModelRequestIntent) {
return request<RouteSimulationResult>(apiClient.post(`/admin/logical-models/${encodeURIComponent(id)}/simulate`, intent));
}