|
|
|
@ -848,6 +848,22 @@ function uniqueStrings(values: string[]): string[] { |
|
|
|
return [...new Set(values)]; |
|
|
|
} |
|
|
|
|
|
|
|
function isViduVideoModel(modelId: string): boolean { |
|
|
|
return /vidu/i.test(modelId); |
|
|
|
} |
|
|
|
|
|
|
|
function appendDynamicInputArray( |
|
|
|
inputs: Record<string, string | string[]>, |
|
|
|
key: string, |
|
|
|
values: string[] |
|
|
|
): void { |
|
|
|
const merged = uniqueStrings([ |
|
|
|
...asStringArray(inputs[key]), |
|
|
|
...values, |
|
|
|
]); |
|
|
|
if (merged.length > 0) inputs[key] = merged; |
|
|
|
} |
|
|
|
|
|
|
|
function normalizeNewApiWGVideoInputs( |
|
|
|
input: GenerationInput, |
|
|
|
dynamicInputs: Record<string, string | string[]> |
|
|
|
@ -859,12 +875,18 @@ function normalizeNewApiWGVideoInputs( |
|
|
|
const images = [...(input.images || [])]; |
|
|
|
const videos: string[] = []; |
|
|
|
const audios: string[] = []; |
|
|
|
const shouldUseViduReferenceVideoField = isViduVideoModel(input.model.id); |
|
|
|
|
|
|
|
for (const [key, value] of Object.entries(dynamicInputs)) { |
|
|
|
if (NEWAPIWG_VIDEO_IMAGE_INPUTS.has(key)) { |
|
|
|
images.push(...asStringArray(value)); |
|
|
|
} else if (NEWAPIWG_VIDEO_INPUTS.has(key)) { |
|
|
|
videos.push(...asStringArray(value)); |
|
|
|
const videoValues = asStringArray(value); |
|
|
|
if (shouldUseViduReferenceVideoField) { |
|
|
|
appendDynamicInputArray(normalizedDynamicInputs, "reference_video_urls", videoValues); |
|
|
|
} else { |
|
|
|
videos.push(...videoValues); |
|
|
|
} |
|
|
|
} else if (NEWAPIWG_VIDEO_AUDIO_INPUTS.has(key)) { |
|
|
|
audios.push(...asStringArray(value)); |
|
|
|
} else { |
|
|
|
|