fix(model-picker): 模型选择 - 修复候选报价显示与同渠道模型跳回 (#556)

Original-Commit: 7a5e17e2112c3c23e081a1ecf3c33a654cf1e907
fix(model-picker): 模型选择 - 修复候选报价显示与同渠道模型跳回
This commit is contained in:
Rou
2026-09-20 22:44:59 +08:00
committed by ddCat
parent 93bc079b89
commit 19c9a207c9
6 changed files with 119 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import { defaultImageCapabilityConfig, modelCapabilityConfigFor, normalizeImageValue, normalizeVideoValue, STANDARD_IMAGE_SIZE_VALUES, videoDurationAllowed, type ImageCapabilityConfig } from "@/lib/model-capabilities";
import { videoResolutionComparisonKey } from "@/lib/video-generation-options";
import { imageSizePresets } from "@/lib/image-size-presets";
import { modelOptionName, resolveModelChannel, selectableModelsByCapability, type AiConfig, type ModelCapability } from "@/stores/use-config-store";
import { modelOptionName, PUBLIC_MODEL_CATALOG_ID, resolveModelChannel, selectableModelsByCapability, type AiConfig, type ModelCapability } from "@/stores/use-config-store";
export type ModelInputSummary = {
textCount: number;
@@ -32,12 +32,20 @@ export type ModelReferenceLimits = {
maxAudios: number;
};
export function isDirectSystemModel(config: AiConfig, value: string) {
if (!value) return false;
const channel = resolveModelChannel(config, value);
const cost = channel.modelCosts?.find((item) => item.model === modelOptionName(value));
return channel.scope === "system" && channel.id !== PUBLIC_MODEL_CATALOG_ID && !cost?.logicalModelId;
}
export function groupModelsByDisplayName(config: AiConfig, models: string[]): DisplayModelGroup[] {
const groups = new Map<string, DisplayModelGroup>();
models.forEach((model) => {
const channel = resolveModelChannel(config, model);
const label = configuredModelDisplayName(config, model);
const key = `${channel.id}\u0000${label.toLocaleLowerCase()}`;
// 平台直连模型是独立的渠道 SKU;同名只用于菜单展示,不能合并能力或自动改选。
const key = isDirectSystemModel(config, model) ? JSON.stringify([channel.id, modelOptionName(model)]) : `${channel.id}\u0000${label.toLocaleLowerCase()}`;
const current = groups.get(key);
if (current) current.models.push(model);
else groups.set(key, { key, label, models: [model] });