增加即梦的生图和生视频功能
This commit is contained in:
1 parent
a9a4cdf125
commit
542246e4ce
20 files changed
+1008
-53
No files matched your search
@@ -23,7 +23,7 @@ export type SeedanceCreateInput = {
|
||||
};
|
||||
|
||||
export type SeedanceQueryResult = {
|
||||
status: "queued" | "running" | "succeeded" | "failed" | "cancelled";
|
||||
status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "expired";
|
||||
resultUrl?: string;
|
||||
errorMessage?: string;
|
||||
usage?: SeedanceUsage;
|
||||
@@ -49,11 +49,15 @@ export function getSeedanceConfig() {
|
||||
export async function createSeedanceTask(input: SeedanceCreateInput) {
|
||||
const config = getSeedanceConfig();
|
||||
if (!config.apiKey) throw new Error("缺少 SEEDANCE_API_KEY。请在 .env.local 配置火山方舟 API Key。");
|
||||
const materialContent = materialContentForProvider(input.materials, input.origin);
|
||||
if (materialContent.length > 4) {
|
||||
throw new Error("Seedance 2.0 最多支持 4 个素材(加上文本后 content 最多 5 项)。");
|
||||
}
|
||||
const payload = {
|
||||
model: config.model,
|
||||
content: [
|
||||
{ type: "text", text: input.prompt },
|
||||
...materialContentForProvider(input.materials, input.origin)
|
||||
...materialContent
|
||||
],
|
||||
generate_audio: true,
|
||||
ratio: normalizeVideoRatio(input.settings.ratio, config.ratio),
|
||||
@@ -123,7 +127,8 @@ export function extractSeedanceUsage(value: unknown): SeedanceUsage | undefined
|
||||
function normalizeSeedanceStatus(status: unknown): SeedanceQueryResult["status"] {
|
||||
const value = String(status || "").toLowerCase();
|
||||
if (["succeeded", "success", "completed"].includes(value)) return "succeeded";
|
||||
if (["failed", "error", "expired", "timeout"].includes(value)) return "failed";
|
||||
if (["expired", "timeout"].includes(value)) return "expired";
|
||||
if (["failed", "error"].includes(value)) return "failed";
|
||||
if (["cancelled", "canceled"].includes(value)) return "cancelled";
|
||||
if (["running", "processing", "generating"].includes(value)) return "running";
|
||||
return "queued";
|
||||
|
||||
Reference in new issue
Block a user