fix: remove stale canvas video provider references
This commit is contained in:
parent
b22c4c5c2f
commit
7e7685410f
@ -2982,31 +2982,48 @@ export function CanvasChatPanel({
|
||||
[visualModels]
|
||||
);
|
||||
const currentModel = allModels.find((model) => model.id === selectedModelId);
|
||||
const isCanvasVideoModel = useCallback(
|
||||
(model?: (typeof allModels)[number] | null) =>
|
||||
Boolean(
|
||||
model &&
|
||||
isVideoModelDescriptor({
|
||||
providerType: model.providerType,
|
||||
modelId: model.modelId,
|
||||
capabilities: model.capabilities,
|
||||
supportsImageGen: model.supportsImageGen,
|
||||
})
|
||||
),
|
||||
[]
|
||||
);
|
||||
const isCanvasImageModel = useCallback(
|
||||
(model?: (typeof allModels)[number] | null) =>
|
||||
Boolean(
|
||||
model &&
|
||||
isImageGenerationModelDescriptor({
|
||||
providerType: model.providerType,
|
||||
modelId: model.modelId,
|
||||
capabilities: model.capabilities,
|
||||
supportsImageGen: model.supportsImageGen,
|
||||
})
|
||||
),
|
||||
[]
|
||||
);
|
||||
const isCanvasConversationOnlyModel = useCallback(
|
||||
(model?: (typeof allModels)[number] | null) =>
|
||||
Boolean(
|
||||
model &&
|
||||
model.id !== "auto" &&
|
||||
model.isMultimodal &&
|
||||
!isCanvasImageModel(model) &&
|
||||
!isCanvasVideoModel(model)
|
||||
),
|
||||
[isCanvasImageModel, isCanvasVideoModel]
|
||||
);
|
||||
const isVideoModel = Boolean(
|
||||
currentModel &&
|
||||
isVideoModelDescriptor({
|
||||
providerType: currentModel.providerType,
|
||||
modelId: currentModel.modelId,
|
||||
capabilities: currentModel.capabilities,
|
||||
supportsImageGen: currentModel.supportsImageGen,
|
||||
})
|
||||
currentModel && isCanvasVideoModel(currentModel)
|
||||
);
|
||||
const isConversationModel = Boolean(
|
||||
currentModel &&
|
||||
currentModel.id !== "auto" &&
|
||||
currentModel.isMultimodal &&
|
||||
!isImageGenerationModelDescriptor({
|
||||
providerType: currentModel.providerType,
|
||||
modelId: currentModel.modelId,
|
||||
capabilities: currentModel.capabilities,
|
||||
supportsImageGen: currentModel.supportsImageGen,
|
||||
}) &&
|
||||
!isVideoModelDescriptor({
|
||||
providerType: currentModel.providerType,
|
||||
modelId: currentModel.modelId,
|
||||
capabilities: currentModel.capabilities,
|
||||
supportsImageGen: currentModel.supportsImageGen,
|
||||
})
|
||||
currentModel && isCanvasConversationOnlyModel(currentModel)
|
||||
);
|
||||
const isAgentModel =
|
||||
!isDetailGenerationMode &&
|
||||
@ -3530,8 +3547,7 @@ export function CanvasChatPanel({
|
||||
allModels.find(
|
||||
(model) =>
|
||||
model.id === lastConversationModelId &&
|
||||
model.isMultimodal &&
|
||||
!VIDEO_PROVIDER_TYPES.has(model.providerType)
|
||||
isCanvasConversationOnlyModel(model)
|
||||
)?.id || "auto";
|
||||
currentModelIdRef.current = preferredAgentModelId;
|
||||
setSelectedModelId(preferredAgentModelId);
|
||||
@ -3557,8 +3573,8 @@ export function CanvasChatPanel({
|
||||
(model) =>
|
||||
model.id === lastImageModelId &&
|
||||
model.id !== "auto" &&
|
||||
!model.isMultimodal &&
|
||||
!VIDEO_PROVIDER_TYPES.has(model.providerType)
|
||||
isCanvasImageModel(model) &&
|
||||
!model.isMultimodal
|
||||
)?.id || firstImageModelId;
|
||||
|
||||
if (!preferredImageModelId) {
|
||||
@ -3572,9 +3588,8 @@ export function CanvasChatPanel({
|
||||
}
|
||||
|
||||
const preferredVideoModelId =
|
||||
allModels.find(
|
||||
(model) => model.id === lastVideoModelId && VIDEO_PROVIDER_TYPES.has(model.providerType)
|
||||
)?.id || firstVideoModelId;
|
||||
allModels.find((model) => model.id === lastVideoModelId && isCanvasVideoModel(model))?.id ||
|
||||
firstVideoModelId;
|
||||
|
||||
if (!preferredVideoModelId) {
|
||||
toast.error("当前没有可用的视频模型");
|
||||
@ -3591,6 +3606,9 @@ export function CanvasChatPanel({
|
||||
firstVideoModelId,
|
||||
lastConversationModelId,
|
||||
lastImageModelId,
|
||||
isCanvasConversationOnlyModel,
|
||||
isCanvasImageModel,
|
||||
isCanvasVideoModel,
|
||||
lastVideoModelId,
|
||||
]
|
||||
);
|
||||
@ -3968,16 +3986,8 @@ export function CanvasChatPanel({
|
||||
const autoContext = autoContextRef.current || undefined;
|
||||
const contextPayload = buildContextPayload();
|
||||
const requestModel = allModels.find((model) => model.id === currentModelIdRef.current);
|
||||
const requestIsVideoModel = Boolean(
|
||||
requestModel && VIDEO_PROVIDER_TYPES.has(requestModel.providerType)
|
||||
);
|
||||
const requestIsConversationModel = Boolean(
|
||||
requestModel &&
|
||||
requestModel.id !== "auto" &&
|
||||
requestModel.isMultimodal &&
|
||||
!requestModel.supportsImageGen &&
|
||||
!requestIsVideoModel
|
||||
);
|
||||
const requestIsVideoModel = isCanvasVideoModel(requestModel);
|
||||
const requestIsConversationModel = isCanvasConversationOnlyModel(requestModel);
|
||||
hiddenPromptRef.current = null;
|
||||
autoContextRef.current = null;
|
||||
return {
|
||||
@ -10033,16 +10043,8 @@ export function CanvasChatPanel({
|
||||
value={modelSelectValue}
|
||||
onValueChange={(value) => {
|
||||
const nextModel = allModels.find((model) => model.id === value);
|
||||
const nextIsVideoModel = Boolean(
|
||||
nextModel && VIDEO_PROVIDER_TYPES.has(nextModel.providerType)
|
||||
);
|
||||
const nextIsConversationModel = Boolean(
|
||||
nextModel &&
|
||||
nextModel.id !== "auto" &&
|
||||
nextModel.isMultimodal &&
|
||||
!nextModel.supportsImageGen &&
|
||||
!nextIsVideoModel
|
||||
);
|
||||
const nextIsVideoModel = isCanvasVideoModel(nextModel);
|
||||
const nextIsConversationModel = isCanvasConversationOnlyModel(nextModel);
|
||||
currentModelIdRef.current = value;
|
||||
setSelectedModelId(value);
|
||||
if (value === "auto" || nextIsConversationModel) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user