fix(canvas): honor model sort order and hide video models in image mode
This commit is contained in:
parent
6ff83ee92a
commit
0534560f7d
@ -1314,6 +1314,7 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
|||||||
modelId: string;
|
modelId: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
avatarUrl?: string | null;
|
avatarUrl?: string | null;
|
||||||
|
sortOrder?: number;
|
||||||
providerType: string;
|
providerType: string;
|
||||||
supportsVision?: boolean;
|
supportsVision?: boolean;
|
||||||
supportsImageGen?: boolean;
|
supportsImageGen?: boolean;
|
||||||
@ -1356,12 +1357,21 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
|||||||
const aiDetailGenerationEnabled = siteSettings?.aiDetailGenerationEnabled === true;
|
const aiDetailGenerationEnabled = siteSettings?.aiDetailGenerationEnabled === true;
|
||||||
|
|
||||||
const VIDEO_PROVIDER_TYPES = new Set(["volcano-video", "doubao-video", "qianwen-video", "fal-video"]);
|
const VIDEO_PROVIDER_TYPES = new Set(["volcano-video", "doubao-video", "qianwen-video", "fal-video"]);
|
||||||
const visualModels =
|
const visualModels = useMemo(() => {
|
||||||
modelsData?.models?.filter(
|
const filtered =
|
||||||
(model) =>
|
modelsData?.models?.filter(
|
||||||
model.modelId !== "volcano-video-master" &&
|
(model) =>
|
||||||
(model.supportsImageGen || VIDEO_PROVIDER_TYPES.has(model.providerType))
|
model.modelId !== "volcano-video-master" &&
|
||||||
) || [];
|
(model.supportsImageGen || VIDEO_PROVIDER_TYPES.has(model.providerType))
|
||||||
|
) || [];
|
||||||
|
|
||||||
|
return [...filtered].sort((a, b) => {
|
||||||
|
const leftOrder = Number.isFinite(a.sortOrder as number) ? Number(a.sortOrder) : 0;
|
||||||
|
const rightOrder = Number.isFinite(b.sortOrder as number) ? Number(b.sortOrder) : 0;
|
||||||
|
if (leftOrder !== rightOrder) return leftOrder - rightOrder;
|
||||||
|
return String(a.displayName || "").localeCompare(String(b.displayName || ""), "zh-Hans-CN");
|
||||||
|
});
|
||||||
|
}, [modelsData?.models]);
|
||||||
|
|
||||||
// Agent模式(自动路由)模型选项
|
// Agent模式(自动路由)模型选项
|
||||||
const SMART_AUTO_MODEL = {
|
const SMART_AUTO_MODEL = {
|
||||||
@ -1369,6 +1379,7 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
|||||||
modelId: "auto",
|
modelId: "auto",
|
||||||
displayName: "Agent模式",
|
displayName: "Agent模式",
|
||||||
avatarUrl: modelsData?.agentModel?.avatarUrl || null,
|
avatarUrl: modelsData?.agentModel?.avatarUrl || null,
|
||||||
|
sortOrder: -999,
|
||||||
providerType: "auto",
|
providerType: "auto",
|
||||||
supportsImageGen: true,
|
supportsImageGen: true,
|
||||||
imageGenConfig: modelsData?.agentModel?.imageGenConfig || undefined,
|
imageGenConfig: modelsData?.agentModel?.imageGenConfig || undefined,
|
||||||
@ -1376,6 +1387,13 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
|||||||
|
|
||||||
// 所有可选模型(Agent模式 + 可视化模型)
|
// 所有可选模型(Agent模式 + 可视化模型)
|
||||||
const allModels = [SMART_AUTO_MODEL, ...visualModels];
|
const allModels = [SMART_AUTO_MODEL, ...visualModels];
|
||||||
|
const imageOnlyModels = useMemo(
|
||||||
|
() =>
|
||||||
|
visualModels.filter(
|
||||||
|
(model) => model.supportsImageGen && !VIDEO_PROVIDER_TYPES.has(model.providerType)
|
||||||
|
),
|
||||||
|
[visualModels]
|
||||||
|
);
|
||||||
const videoOnlyModels = useMemo(
|
const videoOnlyModels = useMemo(
|
||||||
() => visualModels.filter((model) => VIDEO_PROVIDER_TYPES.has(model.providerType)),
|
() => visualModels.filter((model) => VIDEO_PROVIDER_TYPES.has(model.providerType)),
|
||||||
[visualModels]
|
[visualModels]
|
||||||
@ -1389,8 +1407,8 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
|||||||
if (isVideoModel) {
|
if (isVideoModel) {
|
||||||
return videoOnlyModels;
|
return videoOnlyModels;
|
||||||
}
|
}
|
||||||
return allModels;
|
return [SMART_AUTO_MODEL, ...imageOnlyModels];
|
||||||
}, [SMART_AUTO_MODEL, allModels, isDetailGenerationMode, isVideoModel, videoOnlyModels]);
|
}, [SMART_AUTO_MODEL, imageOnlyModels, isDetailGenerationMode, isVideoModel, videoOnlyModels]);
|
||||||
const modelSelectValue = selectableModels.some((model) => model.id === selectedModelId)
|
const modelSelectValue = selectableModels.some((model) => model.id === selectedModelId)
|
||||||
? selectedModelId
|
? selectedModelId
|
||||||
: selectableModels[0]?.id || selectedModelId;
|
: selectableModels[0]?.id || selectedModelId;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user