增加即梦图片5.0和视频2.5的能力
This commit is contained in:
1 parent
542246e4ce
commit
88a4268d40
55 files changed
+1412
-200
No files matched your search
@@ -10,12 +10,13 @@ import { DEFAULT_OWNER_ID } from "@/lib/server/runtime";
|
||||
import { importRemoteAssetAsAsset } from "@/lib/server/storage";
|
||||
import { createSeedanceTask, getSeedanceConfig, querySeedanceTask, type SeedanceSettings } from "@/lib/seedance/client";
|
||||
import type { BillingJobCharge, GenerationJob, UsageContext } from "@/lib/types";
|
||||
import { normalizeVideoDuration, normalizeVideoRatio, normalizeVideoResolution } from "@/lib/video-settings";
|
||||
import { VIDEO_DURATION_DEFAULT, clampVideoDuration, isSupportedSeedanceModel, normalizeSeedanceModel, normalizeVideoDuration, normalizeVideoRatio, normalizeVideoResolution } from "@/lib/video-settings";
|
||||
import { bailianResultUrls, bailianStatus, bailianTaskId, buildBailianVideoPayload, getBailianConfig, queryBailianTask, submitBailianTask } from "@/lib/bailian/client";
|
||||
|
||||
export type VideoCreationEngine = "seedance" | "bailian";
|
||||
|
||||
export type SubmitVideoJobInput = PromptAssemblyInput & {
|
||||
model?: string;
|
||||
ownerId?: string;
|
||||
externalClientId?: string;
|
||||
prompt?: string;
|
||||
@@ -114,6 +115,10 @@ function prepareVideoGeneration(input: SubmitVideoJobInput, origin: string): Pre
|
||||
? input.engine
|
||||
: configuredEngine;
|
||||
const config = getSeedanceConfig();
|
||||
if (engine === "seedance" && input.model !== undefined && !isSupportedSeedanceModel(input.model)) {
|
||||
throw new Error("不支持的 Seedance 视频模型。");
|
||||
}
|
||||
const model = normalizeSeedanceModel(input.model, config.model);
|
||||
const assembled = assemblePrompt({
|
||||
...input,
|
||||
mode: "video",
|
||||
@@ -127,15 +132,17 @@ function prepareVideoGeneration(input: SubmitVideoJobInput, origin: string): Pre
|
||||
buildBailianVideoPayload({ prompt: finalPrompt, materials: assembled.materials, origin, settings });
|
||||
} else {
|
||||
settings.ratio = normalizeVideoRatio(settings.ratio, config.ratio);
|
||||
settings.duration = normalizeVideoDuration(settings.duration) ?? config.duration;
|
||||
settings.resolution = normalizeVideoResolution(settings.resolution, config.model, config.resolution);
|
||||
settings.duration = normalizeVideoDuration(settings.duration, model)
|
||||
?? clampVideoDuration(config.duration, VIDEO_DURATION_DEFAULT, { model });
|
||||
settings.resolution = normalizeVideoResolution(settings.resolution, model, config.resolution);
|
||||
}
|
||||
const missingProviderCredentials = engine === "bailian" ? !getBailianConfig().apiKey : !config.apiKey;
|
||||
const requestPayload = {
|
||||
input,
|
||||
assembled,
|
||||
settings,
|
||||
engine
|
||||
engine,
|
||||
...(engine === "seedance" ? { model } : {})
|
||||
};
|
||||
return {
|
||||
ownerId,
|
||||
@@ -146,7 +153,7 @@ function prepareVideoGeneration(input: SubmitVideoJobInput, origin: string): Pre
|
||||
settings,
|
||||
missingProviderCredentials,
|
||||
provider: engine,
|
||||
reqKey: engine === "bailian" ? getBailianConfig().videoModel : config.model,
|
||||
reqKey: engine === "bailian" ? getBailianConfig().videoModel : model,
|
||||
requestPayload
|
||||
};
|
||||
}
|
||||
@@ -180,7 +187,7 @@ async function dispatchVideoJob(job: GenerationJob, origin: string): Promise<Gen
|
||||
if (!providerTaskId) throw new Error("视频任务响应缺少 task_id。");
|
||||
return updateGenerationJob(job.id, { status: "running", providerTaskId, responsePayload: response });
|
||||
}
|
||||
const response = await createSeedanceTask({ prompt: job.prompt || "", settings, materials, origin });
|
||||
const response = await createSeedanceTask({ model: job.reqKey, prompt: job.prompt || "", settings, materials, origin });
|
||||
return updateGenerationJob(job.id, { status: "running", providerTaskId: response.providerTaskId, responsePayload: response.raw });
|
||||
} catch (error) {
|
||||
job = await updateGenerationJob(job.id, {
|
||||
|
||||
Reference in new issue
Block a user