feat(models): 统一模型规格价格与路由

This commit is contained in:
kinoko committed 2026-08-22 17:00:08 +08:00
1 parent d268a938e5
commit 236b850177
36 files changed
+3404 -421

No files matched your search

+9 -4
View File
@@ -11,7 +11,7 @@ import type { ModelCapabilityConfig } from "@/lib/model-capabilities";
import { useLocalDreaminaModelStore } from "@/stores/use-local-dreamina-model-store";
import { useUserStore } from "@/stores/use-user-store";
import type { DreaminaLocalModel } from "@/services/local-dreamina-model-catalog";
import type { CapabilitySpec } from "@/services/api/logical-models";
import type { CapabilitySpec, PublicLogicalModelPriceTier } from "@/services/api/logical-models";
export type ApiCallFormat = "openai" | "gemini";
export type ChannelInterfaceType = ModelProtocol;
@@ -31,6 +31,8 @@ export type ModelChannel = {
apiFormat: ApiCallFormat;
interfaceType?: ChannelInterfaceType;
models: string[];
// 仅平台目录使用:将已保存的旧 SKU 选择重定向到当前模型家族。
modelAliases?: Record<string, string>;
scope?: "system" | "user";
enabled?: boolean;
hasApiKey?: boolean;
@@ -53,6 +55,7 @@ export type ModelChannel = {
logicalModelId?: string;
logicalCapabilitySpec?: CapabilitySpec;
logicalCapabilityProfiles?: CapabilitySpec[];
logicalPriceTiers?: PublicLogicalModelPriceTier[];
defaultOptions?: Record<string, unknown>;
}>;
transport?: "backend-channel" | "local-runtime";
@@ -481,10 +484,12 @@ export function normalizeModelOptionValue(value: unknown, channels: ModelChannel
const decoded = decodeChannelModel(model);
if (decoded) {
const channel = channels.find((item) => item.id === decoded.channelId);
return channel && channel.models.includes(decoded.model) ? model : "";
const resolved = channel?.modelAliases?.[decoded.model] || decoded.model;
return channel && channel.models.includes(resolved) ? encodeChannelModel(channel.id, resolved) : "";
}
const channel = channels.find((item) => item.models.includes(model)) || channels[0];
return channel && channel.models.includes(model) ? encodeChannelModel(channel.id, model) : "";
const channel = channels.find((item) => item.models.includes(model) || Boolean(item.modelAliases?.[model])) || channels[0];
const resolved = channel?.modelAliases?.[model] || model;
return channel && channel.models.includes(resolved) ? encodeChannelModel(channel.id, resolved) : "";
}
export function resolveModelChannel(config: AiConfig, value: string) {