fix: align video generation payloads
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
swapFirstLastFrameUploads as sharedSwapFirstLastFrameUploads,
|
||||
uploadPlaygroundFiles as sharedUploadPlaygroundFiles,
|
||||
UploadAttachmentList as SharedUploadAttachmentList,
|
||||
videoGenerationContentFromPromptAndUploads as sharedVideoGenerationContentFromPromptAndUploads,
|
||||
allowedMediaUploadKinds as sharedAllowedMediaUploadKinds,
|
||||
type PlaygroundUpload,
|
||||
type PlaygroundUploadRole,
|
||||
@@ -283,19 +284,25 @@ export function PlaygroundPage(props: {
|
||||
setMediaMessage('');
|
||||
try {
|
||||
const requestPrompt = replacePlaygroundResourceTokens(trimmedPrompt, runUploads, runMode);
|
||||
const uploadPayload = sharedMediaUploadRequestPayload(runUploads, runMode, videoMode);
|
||||
const requestPayload = {
|
||||
model: runModel,
|
||||
prompt: requestPrompt,
|
||||
...mediaRequestPayload(runSettings, runMode),
|
||||
...videoModeRequestPayload(runMode, videoMode, runUploads, runModelOption),
|
||||
...uploadPayload,
|
||||
};
|
||||
const response = runMode === 'video'
|
||||
? await createVideoGenerationTask(credential, requestPayload)
|
||||
: runUploads.some((item) => item.kind === 'image')
|
||||
let response: { task: GatewayTask; next: Record<string, string> };
|
||||
if (runMode === 'video') {
|
||||
response = await createVideoGenerationTask(credential, {
|
||||
model: runModel,
|
||||
content: sharedVideoGenerationContentFromPromptAndUploads(requestPrompt, runUploads, videoMode),
|
||||
...mediaRequestPayload(runSettings, 'video'),
|
||||
});
|
||||
} else {
|
||||
const uploadPayload = sharedMediaUploadRequestPayload(runUploads, 'image');
|
||||
const requestPayload = {
|
||||
model: runModel,
|
||||
prompt: requestPrompt,
|
||||
...mediaRequestPayload(runSettings, 'image'),
|
||||
...uploadPayload,
|
||||
};
|
||||
response = runUploads.some((item) => item.kind === 'image')
|
||||
? await createImageEditTask(credential, requestPayload)
|
||||
: await createImageGenerationTask(credential, requestPayload);
|
||||
}
|
||||
setMediaRuns((current) => updateMediaRun(current, localId, { status: response.task.status, task: response.task }));
|
||||
if (!overrides) {
|
||||
setMediaUploads([]);
|
||||
@@ -674,31 +681,6 @@ function mediaPromptPlaceholder(mode: PlaygroundMode) {
|
||||
return placeholderByMode.chat;
|
||||
}
|
||||
|
||||
function videoModeRequestPayload(
|
||||
mode: Exclude<PlaygroundMode, 'chat'>,
|
||||
videoMode: VideoCreateMode,
|
||||
uploads: PlaygroundUpload[],
|
||||
modelOption?: ModelOption,
|
||||
) {
|
||||
if (mode !== 'video') return {};
|
||||
const modelTypes = new Set(modelOption?.models.flatMap((model) => model.modelType) ?? []);
|
||||
if (videoMode === 'first_last_frame') {
|
||||
const modelType = modelTypes.has('video_first_last_frame') ? 'video_first_last_frame' : 'image_to_video';
|
||||
return { capabilityType: modelType, model_type: modelType };
|
||||
}
|
||||
if (videoMode === 'omni_reference' || uploads.length > 0) {
|
||||
const modelType = modelTypes.has('omni_video')
|
||||
? 'omni_video'
|
||||
: modelTypes.has('video_reference')
|
||||
? 'video_reference'
|
||||
: modelTypes.has('image_to_video')
|
||||
? 'image_to_video'
|
||||
: 'video_generate';
|
||||
return { capabilityType: modelType, model_type: modelType };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
function filterModelsForMode(models: PlatformModel[], mode: PlaygroundMode, hasReference: boolean, videoMode: VideoCreateMode) {
|
||||
if (mode === 'chat') {
|
||||
return filterWithFallback(models, ['text_generate', 'chat', 'responses', 'text']);
|
||||
|
||||
Reference in New Issue
Block a user