fix: include runway models in canvas video mode
This commit is contained in:
parent
dae5581c76
commit
b22c4c5c2f
@ -6,17 +6,13 @@ import {
|
|||||||
getUserById,
|
getUserById,
|
||||||
} from "@/lib/db/queries";
|
} from "@/lib/db/queries";
|
||||||
import { buildVideoToolCapability } from "@/lib/ai/video-tool-capability";
|
import { buildVideoToolCapability } from "@/lib/ai/video-tool-capability";
|
||||||
|
import {
|
||||||
|
isImageGenerationModelDescriptor,
|
||||||
|
isVideoModelDescriptor,
|
||||||
|
} from "@/lib/ai/model-classification";
|
||||||
import { ChatSDKError } from "@/lib/errors";
|
import { ChatSDKError } from "@/lib/errors";
|
||||||
import { isAiModelAgentAuto, isAiModelMultimodal } from "@/lib/db/ai-model-flags";
|
import { isAiModelAgentAuto, isAiModelMultimodal } from "@/lib/db/ai-model-flags";
|
||||||
|
|
||||||
const VIDEO_PROVIDER_TYPES = new Set([
|
|
||||||
"volcano-video",
|
|
||||||
"doubao-video",
|
|
||||||
"qianwen-video",
|
|
||||||
"fal-video",
|
|
||||||
"ruxa-video",
|
|
||||||
]);
|
|
||||||
|
|
||||||
function isNanoBananaProModel(model: { displayName?: string | null; modelId?: string | null }) {
|
function isNanoBananaProModel(model: { displayName?: string | null; modelId?: string | null }) {
|
||||||
const displayName = String(model.displayName || "").toLowerCase();
|
const displayName = String(model.displayName || "").toLowerCase();
|
||||||
const modelId = String(model.modelId || "").toLowerCase();
|
const modelId = String(model.modelId || "").toLowerCase();
|
||||||
@ -103,14 +99,34 @@ export async function GET() {
|
|||||||
}));
|
}));
|
||||||
const preferredNanoBananaModel = models.find(
|
const preferredNanoBananaModel = models.find(
|
||||||
(model) =>
|
(model) =>
|
||||||
model.supportsImageGen &&
|
isImageGenerationModelDescriptor({
|
||||||
!VIDEO_PROVIDER_TYPES.has(model.providerType || "") &&
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
}) &&
|
||||||
|
!isVideoModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
}) &&
|
||||||
isNanoBananaProModel(model)
|
isNanoBananaProModel(model)
|
||||||
);
|
);
|
||||||
const preferredImageModel = models.find(
|
const preferredImageModel = models.find(
|
||||||
(model) =>
|
(model) =>
|
||||||
model.supportsImageGen &&
|
isImageGenerationModelDescriptor({
|
||||||
!VIDEO_PROVIDER_TYPES.has(model.providerType || "")
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
}) &&
|
||||||
|
!isVideoModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const resolvedDefaultModelId =
|
const resolvedDefaultModelId =
|
||||||
|
|||||||
@ -47,6 +47,10 @@ import {
|
|||||||
inferOriginalImageUrl,
|
inferOriginalImageUrl,
|
||||||
} from "@/lib/image-url";
|
} from "@/lib/image-url";
|
||||||
import { buildImageProxyUrl } from "@/lib/image-delivery";
|
import { buildImageProxyUrl } from "@/lib/image-delivery";
|
||||||
|
import {
|
||||||
|
isImageGenerationModelDescriptor,
|
||||||
|
isVideoModelDescriptor,
|
||||||
|
} from "@/lib/ai/model-classification";
|
||||||
import type { Attachment, ChatMessage } from "@/lib/types";
|
import type { Attachment, ChatMessage } from "@/lib/types";
|
||||||
import type {
|
import type {
|
||||||
AgentPreset,
|
AgentPreset,
|
||||||
@ -2844,16 +2848,25 @@ export function CanvasChatPanel({
|
|||||||
setSelectedSkillTagId(null);
|
setSelectedSkillTagId(null);
|
||||||
}, [isWorkspacePresentation, selectedSkillTagId]);
|
}, [isWorkspacePresentation, selectedSkillTagId]);
|
||||||
|
|
||||||
const VIDEO_PROVIDER_TYPES = new Set(["volcano-video", "doubao-video", "qianwen-video", "fal-video", "ruxa-video"]);
|
|
||||||
const visualModels = useMemo(() => {
|
const visualModels = useMemo(() => {
|
||||||
const filtered =
|
const filtered =
|
||||||
modelsData?.models?.filter(
|
modelsData?.models?.filter(
|
||||||
(model) =>
|
(model) =>
|
||||||
model.modelId !== "volcano-video-master" &&
|
model.modelId !== "volcano-video-master" &&
|
||||||
(
|
(
|
||||||
model.supportsImageGen ||
|
isImageGenerationModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
}) ||
|
||||||
model.isMultimodal ||
|
model.isMultimodal ||
|
||||||
VIDEO_PROVIDER_TYPES.has(model.providerType)
|
isVideoModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
) || [];
|
) || [];
|
||||||
|
|
||||||
@ -2918,9 +2931,19 @@ export function CanvasChatPanel({
|
|||||||
() =>
|
() =>
|
||||||
visualModels.filter(
|
visualModels.filter(
|
||||||
(model) =>
|
(model) =>
|
||||||
model.supportsImageGen &&
|
isImageGenerationModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
}) &&
|
||||||
!model.isMultimodal &&
|
!model.isMultimodal &&
|
||||||
!VIDEO_PROVIDER_TYPES.has(model.providerType)
|
!isVideoModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
})
|
||||||
),
|
),
|
||||||
[visualModels]
|
[visualModels]
|
||||||
);
|
);
|
||||||
@ -2931,23 +2954,59 @@ export function CanvasChatPanel({
|
|||||||
model.id !== "auto" &&
|
model.id !== "auto" &&
|
||||||
model.id !== modelsData?.agentModel?.id &&
|
model.id !== modelsData?.agentModel?.id &&
|
||||||
model.isMultimodal &&
|
model.isMultimodal &&
|
||||||
!model.supportsImageGen &&
|
!isImageGenerationModelDescriptor({
|
||||||
!VIDEO_PROVIDER_TYPES.has(model.providerType)
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
}) &&
|
||||||
|
!isVideoModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
})
|
||||||
),
|
),
|
||||||
[allModels, modelsData?.agentModel?.id]
|
[allModels, modelsData?.agentModel?.id]
|
||||||
);
|
);
|
||||||
const videoOnlyModels = useMemo(
|
const videoOnlyModels = useMemo(
|
||||||
() => visualModels.filter((model) => VIDEO_PROVIDER_TYPES.has(model.providerType)),
|
() =>
|
||||||
|
visualModels.filter((model) =>
|
||||||
|
isVideoModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
})
|
||||||
|
),
|
||||||
[visualModels]
|
[visualModels]
|
||||||
);
|
);
|
||||||
const currentModel = allModels.find((model) => model.id === selectedModelId);
|
const currentModel = allModels.find((model) => model.id === selectedModelId);
|
||||||
const isVideoModel = Boolean(currentModel && VIDEO_PROVIDER_TYPES.has(currentModel.providerType));
|
const isVideoModel = Boolean(
|
||||||
|
currentModel &&
|
||||||
|
isVideoModelDescriptor({
|
||||||
|
providerType: currentModel.providerType,
|
||||||
|
modelId: currentModel.modelId,
|
||||||
|
capabilities: currentModel.capabilities,
|
||||||
|
supportsImageGen: currentModel.supportsImageGen,
|
||||||
|
})
|
||||||
|
);
|
||||||
const isConversationModel = Boolean(
|
const isConversationModel = Boolean(
|
||||||
currentModel &&
|
currentModel &&
|
||||||
currentModel.id !== "auto" &&
|
currentModel.id !== "auto" &&
|
||||||
currentModel.isMultimodal &&
|
currentModel.isMultimodal &&
|
||||||
!currentModel.supportsImageGen &&
|
!isImageGenerationModelDescriptor({
|
||||||
!VIDEO_PROVIDER_TYPES.has(currentModel.providerType)
|
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,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
const isAgentModel =
|
const isAgentModel =
|
||||||
!isDetailGenerationMode &&
|
!isDetailGenerationMode &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user