@shop-os/modelkit 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -1
- package/dist/catalog.cjs +146 -17
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +146 -17
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +215 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +215 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -378,7 +378,8 @@ var FAL_IMAGE_MODELS = [
|
|
|
378
378
|
constraints: {
|
|
379
379
|
aspectRatios: [...KLING_RATIOS, "adaptive"],
|
|
380
380
|
sizes: ["2K", "4K", "8K"],
|
|
381
|
-
|
|
381
|
+
// fal refuses a reference under 300x300 (422 image_too_small, prod COWORK-5S).
|
|
382
|
+
references: { images: 10, imagePixels: { minWidth: 300, minHeight: 300 } },
|
|
382
383
|
supports: ["count"],
|
|
383
384
|
prompt: { referenceSyntax: "numbered", maxChars: 21e3 }
|
|
384
385
|
},
|
|
@@ -5425,10 +5426,119 @@ var TEXT_MODELS = [
|
|
|
5425
5426
|
})
|
|
5426
5427
|
];
|
|
5427
5428
|
|
|
5428
|
-
// src/catalog/video-
|
|
5429
|
-
var VIDEO_USAGE = { unit: "seconds" };
|
|
5429
|
+
// src/catalog/video-avatars.ts
|
|
5430
5430
|
var MB = 1024 * 1024;
|
|
5431
5431
|
var KLING_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
|
|
5432
|
+
var VEED_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/d540d2bb-0022-4371-8889-48aefaf46bbe.png";
|
|
5433
|
+
var SYNC_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
|
|
5434
|
+
var KIT_AUDIO_CAP_SECONDS = 300;
|
|
5435
|
+
function avatar(row2) {
|
|
5436
|
+
const { min, max, formats, maxBytes } = row2.audio;
|
|
5437
|
+
return {
|
|
5438
|
+
id: row2.id,
|
|
5439
|
+
aliases: row2.aliases,
|
|
5440
|
+
label: row2.label,
|
|
5441
|
+
type: "video",
|
|
5442
|
+
adapter: "fal",
|
|
5443
|
+
providerModelId: row2.providerModelId,
|
|
5444
|
+
lifecycle: "active",
|
|
5445
|
+
exposure: ["cowork", "space_builder"],
|
|
5446
|
+
constraints: {
|
|
5447
|
+
...row2.resolutions !== void 0 && { resolutions: [...row2.resolutions] },
|
|
5448
|
+
references: {
|
|
5449
|
+
images: 1,
|
|
5450
|
+
videos: 0,
|
|
5451
|
+
audios: 1,
|
|
5452
|
+
audioOnly: false,
|
|
5453
|
+
audioSeconds: { ...min !== void 0 && { min }, max },
|
|
5454
|
+
audioFormats: formats,
|
|
5455
|
+
...maxBytes !== void 0 && { audioMaxBytes: maxBytes },
|
|
5456
|
+
min: { images: 1, audios: 1 }
|
|
5457
|
+
},
|
|
5458
|
+
requires: ["references"],
|
|
5459
|
+
supports: [],
|
|
5460
|
+
...row2.promptMaxChars === void 0 ? { noPrompt: true } : { prompt: { referenceSyntax: "descriptive", maxChars: row2.promptMaxChars } },
|
|
5461
|
+
audio: "always"
|
|
5462
|
+
},
|
|
5463
|
+
defaults: row2.resolutions === void 0 ? {} : { resolution: row2.resolutions[0] },
|
|
5464
|
+
usage: { unit: "seconds" },
|
|
5465
|
+
pricingKind: "video_per_second",
|
|
5466
|
+
display: {
|
|
5467
|
+
provider: row2.provider,
|
|
5468
|
+
...row2.logo !== void 0 && { logo: row2.logo },
|
|
5469
|
+
description: row2.description
|
|
5470
|
+
},
|
|
5471
|
+
capabilities: {}
|
|
5472
|
+
};
|
|
5473
|
+
}
|
|
5474
|
+
function heygenAvatar6(tier) {
|
|
5475
|
+
const turbo2 = tier === "turbo";
|
|
5476
|
+
return avatar({
|
|
5477
|
+
id: turbo2 ? "heygen-avatar-6-turbo" : "heygen-avatar-6",
|
|
5478
|
+
aliases: [],
|
|
5479
|
+
label: turbo2 ? "HeyGen Avatar 6 Turbo" : "HeyGen Avatar 6",
|
|
5480
|
+
providerModelId: turbo2 ? "heygen/avatar-6/turbo/image-to-video" : "heygen/avatar-6/image-to-video",
|
|
5481
|
+
provider: "heygen",
|
|
5482
|
+
description: turbo2 ? "HeyGen Avatar 6 Turbo: the lower-cost tier; turns one photo of a person and a speech clip of up to 5 minutes into a talking video as long as the speech, at 1080p or 2K, with an optional motion prompt." : "HeyGen Avatar 6: turns one photo of a person and a speech clip of up to 5 minutes into a talking video as long as the speech, at 1080p or 2K, with an optional motion prompt.",
|
|
5483
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"], maxBytes: 50 * MB },
|
|
5484
|
+
resolutions: ["1080p", "2k"],
|
|
5485
|
+
promptMaxChars: 1200
|
|
5486
|
+
});
|
|
5487
|
+
}
|
|
5488
|
+
function klingAvatar(tier) {
|
|
5489
|
+
const label = tier === "pro" ? "Pro" : "Standard";
|
|
5490
|
+
return avatar({
|
|
5491
|
+
id: `kling-ai-avatar-v2-${tier}`,
|
|
5492
|
+
aliases: [],
|
|
5493
|
+
label: `Kling AI Avatar 2.0 ${label}`,
|
|
5494
|
+
providerModelId: `fal-ai/kling-video/ai-avatar/v2/${tier}`,
|
|
5495
|
+
provider: "kuaishou",
|
|
5496
|
+
logo: KLING_LOGO,
|
|
5497
|
+
description: `Kuaishou Kling AI Avatar 2.0 (${label}): turns one image of a person, animal or character and a 2-300 second audio clip into a talking video as long as the audio.`,
|
|
5498
|
+
audio: { min: 2, max: 300, formats: ["mp3", "wav", "m4a", "aac"], maxBytes: 5 * MB },
|
|
5499
|
+
promptMaxChars: 2500
|
|
5500
|
+
});
|
|
5501
|
+
}
|
|
5502
|
+
function veedFabric(tier) {
|
|
5503
|
+
const fast = tier === "fast";
|
|
5504
|
+
return avatar({
|
|
5505
|
+
id: fast ? "veed-fabric-1.0-fast" : "veed-fabric-1.0",
|
|
5506
|
+
aliases: [fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0"],
|
|
5507
|
+
label: fast ? "VEED Fabric 1.0 Fast" : "VEED Fabric 1.0",
|
|
5508
|
+
providerModelId: fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0",
|
|
5509
|
+
provider: "veed",
|
|
5510
|
+
logo: VEED_LOGO,
|
|
5511
|
+
description: fast ? "VEED Fabric 1.0 Fast: the quicker tier; turns one image and a speech clip into a lip-synced talking video as long as the speech, at 480p or 720p." : "VEED Fabric 1.0: turns one image and a speech clip into a lip-synced talking video as long as the speech, at 480p or 720p.",
|
|
5512
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["mp3", "ogg", "wav", "m4a", "aac"] },
|
|
5513
|
+
resolutions: ["720p", "480p"]
|
|
5514
|
+
});
|
|
5515
|
+
}
|
|
5516
|
+
var VIDEO_AVATAR_MODELS = [
|
|
5517
|
+
heygenAvatar6("regular"),
|
|
5518
|
+
heygenAvatar6("turbo"),
|
|
5519
|
+
klingAvatar("standard"),
|
|
5520
|
+
klingAvatar("pro"),
|
|
5521
|
+
veedFabric("regular"),
|
|
5522
|
+
veedFabric("fast"),
|
|
5523
|
+
// https://fal.ai/models/fal-ai/sync-lipsync/v3/image-to-video/api: image_url and audio_url
|
|
5524
|
+
// only; the video matches the audio's length. sync takes WAV or MP3
|
|
5525
|
+
// (https://sync.so/docs/quickstart); the length is the kit cap.
|
|
5526
|
+
avatar({
|
|
5527
|
+
id: "sync-3-image-to-video",
|
|
5528
|
+
aliases: ["fal-ai/sync-lipsync/v3/image-to-video"],
|
|
5529
|
+
label: "Sync 3 Avatar",
|
|
5530
|
+
providerModelId: "fal-ai/sync-lipsync/v3/image-to-video",
|
|
5531
|
+
provider: "sync",
|
|
5532
|
+
logo: SYNC_LOGO2,
|
|
5533
|
+
description: "Sync 3 (sync-3) image-to-video: animates the face in one image so it lip-syncs to a speech clip, as long as the speech.",
|
|
5534
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"] }
|
|
5535
|
+
})
|
|
5536
|
+
];
|
|
5537
|
+
|
|
5538
|
+
// src/catalog/video-families.ts
|
|
5539
|
+
var VIDEO_USAGE = { unit: "seconds" };
|
|
5540
|
+
var MB2 = 1024 * 1024;
|
|
5541
|
+
var KLING_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
|
|
5432
5542
|
var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
5433
5543
|
var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
5434
5544
|
var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
|
|
@@ -5486,7 +5596,7 @@ function klingMotionControl(tier) {
|
|
|
5486
5596
|
pricingKind: "video_per_second",
|
|
5487
5597
|
display: {
|
|
5488
5598
|
provider: "kuaishou",
|
|
5489
|
-
logo:
|
|
5599
|
+
logo: KLING_LOGO2,
|
|
5490
5600
|
description: `Kuaishou Kling 3.0 Motion Control (${label}): a character image performs the motion of a 3-30 second reference video, keeping its timing and sound.`
|
|
5491
5601
|
},
|
|
5492
5602
|
capabilities: {}
|
|
@@ -5519,7 +5629,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5519
5629
|
pricingKind: "video_per_second",
|
|
5520
5630
|
display: {
|
|
5521
5631
|
provider: "kuaishou",
|
|
5522
|
-
logo:
|
|
5632
|
+
logo: KLING_LOGO2,
|
|
5523
5633
|
description: "Kuaishou Kling O3 Pro: text, start/end frames and up to 7 reference images in one 3-15 second clip with consistent characters and optional native audio."
|
|
5524
5634
|
},
|
|
5525
5635
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
@@ -5550,7 +5660,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5550
5660
|
pricingKind: "video_per_second",
|
|
5551
5661
|
display: {
|
|
5552
5662
|
provider: "kuaishou",
|
|
5553
|
-
logo:
|
|
5663
|
+
logo: KLING_LOGO2,
|
|
5554
5664
|
description: "Kuaishou Kling O3 Pro video edit: change a 3-15 second clip with a prompt and up to 4 reference images while keeping its motion and timing."
|
|
5555
5665
|
},
|
|
5556
5666
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5594,7 +5704,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5594
5704
|
pricingKind: "video_per_second",
|
|
5595
5705
|
display: {
|
|
5596
5706
|
provider: "kuaishou",
|
|
5597
|
-
logo:
|
|
5707
|
+
logo: KLING_LOGO2,
|
|
5598
5708
|
description: "Kuaishou Kling 4.0: text-to-video, start/end frames, or reference-to-video from up to 10 images and 5 videos (30 seconds combined), up to 30 seconds at 720p or 1080p. Prompts name references @Image1, @Video1."
|
|
5599
5709
|
},
|
|
5600
5710
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
@@ -5628,7 +5738,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5628
5738
|
pricingKind: "video_per_second",
|
|
5629
5739
|
display: {
|
|
5630
5740
|
provider: "kuaishou",
|
|
5631
|
-
logo:
|
|
5741
|
+
logo: KLING_LOGO2,
|
|
5632
5742
|
description: "Kuaishou Kling 4.0 video edit: change a 3-30 second clip with a prompt and up to 10 reference images, at 720p or 1080p, as long as the source or a set 3-30 seconds. Prompts name the source @Video1 and images @Image1."
|
|
5633
5743
|
},
|
|
5634
5744
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5669,7 +5779,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5669
5779
|
pricingKind: "video_per_second",
|
|
5670
5780
|
display: {
|
|
5671
5781
|
provider: "kuaishou",
|
|
5672
|
-
logo:
|
|
5782
|
+
logo: KLING_LOGO2,
|
|
5673
5783
|
description: "Kuaishou Kling 4.0 Flash: fast text-to-video, a start frame, or reference-to-video from up to 10 images and 5 videos (20 seconds combined), 3 to 20 seconds at 720p. Prompts name references @Image1, @Video1."
|
|
5674
5784
|
}
|
|
5675
5785
|
},
|
|
@@ -5709,7 +5819,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5709
5819
|
pricingKind: "video_per_second",
|
|
5710
5820
|
display: {
|
|
5711
5821
|
provider: "kuaishou",
|
|
5712
|
-
logo:
|
|
5822
|
+
logo: KLING_LOGO2,
|
|
5713
5823
|
description: "Kuaishou Kling 4.0 Flash video edit: change a 3-20 second clip with a prompt, up to 10 reference images and 4 reference videos (20 seconds in all with the source), at 720p, as long as the source or a set 3-20 seconds. Prompts name the source @Video1."
|
|
5714
5824
|
},
|
|
5715
5825
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5736,7 +5846,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5736
5846
|
...NO_REFERENCES,
|
|
5737
5847
|
audios: 1,
|
|
5738
5848
|
audioSeconds: { min: 2 },
|
|
5739
|
-
audioMaxBytes: 15 *
|
|
5849
|
+
audioMaxBytes: 15 * MB2
|
|
5740
5850
|
},
|
|
5741
5851
|
supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
|
|
5742
5852
|
prompt: H3_PROMPT,
|
|
@@ -5935,7 +6045,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5935
6045
|
audioOnly: false,
|
|
5936
6046
|
audioSeconds: { min: 3, max: 12 },
|
|
5937
6047
|
audioFormats: ["mp3"],
|
|
5938
|
-
audioMaxBytes: 50 *
|
|
6048
|
+
audioMaxBytes: 50 * MB2
|
|
5939
6049
|
},
|
|
5940
6050
|
// Sound (dialogue and effects) is a reference-to-video option; image-to-video is silent.
|
|
5941
6051
|
supports: ["seed", "generateAudio", "safetyChecker"],
|
|
@@ -5976,7 +6086,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5976
6086
|
audioOnly: false,
|
|
5977
6087
|
audioSeconds: { min: 4, max: 300 },
|
|
5978
6088
|
audioFormats: ["wav", "mp3"],
|
|
5979
|
-
audioMaxBytes: 15 *
|
|
6089
|
+
audioMaxBytes: 15 * MB2,
|
|
5980
6090
|
min: { images: 1, audios: 1 }
|
|
5981
6091
|
},
|
|
5982
6092
|
requires: ["references"],
|
|
@@ -7079,6 +7189,7 @@ var VIDEO_MODELS = [
|
|
|
7079
7189
|
capabilities: {}
|
|
7080
7190
|
},
|
|
7081
7191
|
...VIDEO_FAMILY_MODELS,
|
|
7192
|
+
...VIDEO_AVATAR_MODELS,
|
|
7082
7193
|
...LUMA_VIDEO_MODELS
|
|
7083
7194
|
];
|
|
7084
7195
|
|
|
@@ -10093,6 +10204,15 @@ var KLING_O3_IMAGE_CAP = 7;
|
|
|
10093
10204
|
var KLING_V4_IMAGE_CAP = 10;
|
|
10094
10205
|
var TURBO_AUDIO_MIN_SECONDS = 2;
|
|
10095
10206
|
var OMNIHUMAN_AUDIO_SECONDS = { min: 4, max: 300 };
|
|
10207
|
+
var AVATAR_AUDIO = [
|
|
10208
|
+
["heygen/avatar-6/image-to-video", { max: 300 }],
|
|
10209
|
+
["heygen/avatar-6/turbo/image-to-video", { max: 300 }],
|
|
10210
|
+
["fal-ai/kling-video/ai-avatar/v2/standard", { min: 2, max: 300 }],
|
|
10211
|
+
["fal-ai/kling-video/ai-avatar/v2/pro", { min: 2, max: 300 }],
|
|
10212
|
+
["veed/fabric-1.0", { max: 300, urlOnly: true }],
|
|
10213
|
+
["veed/fabric-1.0/fast", { max: 300, urlOnly: true }],
|
|
10214
|
+
["fal-ai/sync-lipsync/v3/image-to-video", { max: 300, urlOnly: true }]
|
|
10215
|
+
];
|
|
10096
10216
|
function missing(message) {
|
|
10097
10217
|
return { code: "missing_input", message };
|
|
10098
10218
|
}
|
|
@@ -10226,7 +10346,10 @@ function viduQ4(req) {
|
|
|
10226
10346
|
}
|
|
10227
10347
|
return req.firstFrame === void 0 ? missing("needs a start frame or reference images") : void 0;
|
|
10228
10348
|
}
|
|
10229
|
-
function
|
|
10349
|
+
function isPublicUrl(ref) {
|
|
10350
|
+
return "url" in ref && !ref.url.startsWith("data:");
|
|
10351
|
+
}
|
|
10352
|
+
function imageAndAudio(req, audioSeconds) {
|
|
10230
10353
|
const frames = noFrames(req);
|
|
10231
10354
|
if (frames !== void 0) return frames;
|
|
10232
10355
|
if (count(req.referenceVideos) > 0) return unsupported3("takes no reference videos");
|
|
@@ -10238,9 +10361,12 @@ function omnihuman(req) {
|
|
|
10238
10361
|
if (extraImages.length > 0 || extraAudios.length > 0) {
|
|
10239
10362
|
return unsupported3("takes exactly one image and one audio clip");
|
|
10240
10363
|
}
|
|
10241
|
-
|
|
10364
|
+
if (audioSeconds.urlOnly === true && !(isPublicUrl(image) && isPublicUrl(audio))) {
|
|
10365
|
+
return unsupported3("takes its image and audio as public URLs, not inline bytes");
|
|
10366
|
+
}
|
|
10367
|
+
return inputSeconds("audio", audio, audioSeconds);
|
|
10242
10368
|
}
|
|
10243
|
-
var RULES =
|
|
10369
|
+
var RULES = new Map([
|
|
10244
10370
|
[MOTION_PRO, motionControl],
|
|
10245
10371
|
[MOTION_STANDARD, motionControl],
|
|
10246
10372
|
[O3_REFERENCE, o3Reference],
|
|
@@ -10257,7 +10383,10 @@ var RULES = /* @__PURE__ */ new Map([
|
|
|
10257
10383
|
[HAPPY_HORSE, happyHorse],
|
|
10258
10384
|
[HAPPY_HORSE_EDIT, happyHorseEdit],
|
|
10259
10385
|
[VIDU_Q4, viduQ4],
|
|
10260
|
-
[OMNIHUMAN_V2,
|
|
10386
|
+
[OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
|
|
10387
|
+
...AVATAR_AUDIO.map(
|
|
10388
|
+
([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
|
|
10389
|
+
)
|
|
10261
10390
|
]);
|
|
10262
10391
|
function falVideoProblem(providerModelId, req) {
|
|
10263
10392
|
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
@@ -11834,11 +11963,11 @@ function toolInput(ctx, req, output) {
|
|
|
11834
11963
|
}
|
|
11835
11964
|
var EXR_DEFAULT_PROMPT = "The same video in high dynamic range, with unchanged content, motion, framing and timing.";
|
|
11836
11965
|
async function submitFalVideoTool(req, ctx, opts) {
|
|
11837
|
-
const
|
|
11838
|
-
if (!
|
|
11966
|
+
const plan5 = planVideoTool(ctx.model, req);
|
|
11967
|
+
if (!plan5.ok) {
|
|
11839
11968
|
throw new ModelKitError({
|
|
11840
11969
|
code: "unsupported_option",
|
|
11841
|
-
message:
|
|
11970
|
+
message: plan5.error,
|
|
11842
11971
|
provider: "fal",
|
|
11843
11972
|
model: ctx.model.id,
|
|
11844
11973
|
retryable: false
|
|
@@ -11846,7 +11975,7 @@ async function submitFalVideoTool(req, ctx, opts) {
|
|
|
11846
11975
|
}
|
|
11847
11976
|
const target = new URL(`${FAL_QUEUE_ORIGIN}/${ctx.model.providerModelId}`);
|
|
11848
11977
|
if (opts.webhookUrl !== void 0) target.searchParams.set("fal_webhook", opts.webhookUrl);
|
|
11849
|
-
const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req,
|
|
11978
|
+
const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req, plan5.output));
|
|
11850
11979
|
const parsed = submitResponseSchema.safeParse(await readJson(ctx, res));
|
|
11851
11980
|
if (!parsed.success) {
|
|
11852
11981
|
throw new ModelKitError({
|
|
@@ -11864,7 +11993,7 @@ async function submitFalVideoTool(req, ctx, opts) {
|
|
|
11864
11993
|
statusUrl: parsed.data.status_url,
|
|
11865
11994
|
responseUrl: parsed.data.response_url,
|
|
11866
11995
|
cancelUrl: parsed.data.cancel_url,
|
|
11867
|
-
output:
|
|
11996
|
+
output: plan5.output
|
|
11868
11997
|
};
|
|
11869
11998
|
}
|
|
11870
11999
|
async function falVideoToolStatus(sub, ctx) {
|
|
@@ -12186,14 +12315,14 @@ function planFalImage(req, providerModelId, model) {
|
|
|
12186
12315
|
const exact = falExactSize(spec, req);
|
|
12187
12316
|
const call = { label: spec.label, req, refs, edit: edit2, ...exact !== void 0 && { exact } };
|
|
12188
12317
|
const built = family.build(call, model);
|
|
12189
|
-
const
|
|
12318
|
+
const plan5 = {
|
|
12190
12319
|
endpoint: edit2 && family.editEndpoint !== void 0 ? family.editEndpoint : id,
|
|
12191
12320
|
input: built.input,
|
|
12192
12321
|
output: family.output ?? "images"
|
|
12193
12322
|
};
|
|
12194
|
-
if (built.imageQuality !== void 0)
|
|
12195
|
-
if (built.imageSize !== void 0)
|
|
12196
|
-
return
|
|
12323
|
+
if (built.imageQuality !== void 0) plan5.imageQuality = built.imageQuality;
|
|
12324
|
+
if (built.imageSize !== void 0) plan5.imageSize = built.imageSize;
|
|
12325
|
+
return plan5;
|
|
12197
12326
|
}
|
|
12198
12327
|
var FalFileSchema = z17.object({ url: z17.string(), content_type: z17.string().nullish() });
|
|
12199
12328
|
var ImagesPayloadSchema = z17.object({ images: z17.array(FalFileSchema) });
|
|
@@ -12215,18 +12344,18 @@ async function downloadFalFile(ctx, file) {
|
|
|
12215
12344
|
const mime = res.headers.get("content-type") ?? file.content_type ?? "";
|
|
12216
12345
|
return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
|
|
12217
12346
|
}
|
|
12218
|
-
function filesOf(payload,
|
|
12219
|
-
if (
|
|
12347
|
+
function filesOf(payload, plan5) {
|
|
12348
|
+
if (plan5.output === "image") {
|
|
12220
12349
|
const parsed2 = ImagePayloadSchema.safeParse(payload);
|
|
12221
12350
|
return parsed2.success ? [parsed2.data.image] : [];
|
|
12222
12351
|
}
|
|
12223
12352
|
const parsed = ImagesPayloadSchema.safeParse(payload);
|
|
12224
12353
|
return parsed.success ? parsed.data.images : [];
|
|
12225
12354
|
}
|
|
12226
|
-
async function collectFalPlanImages(payload,
|
|
12227
|
-
const files = filesOf(payload,
|
|
12355
|
+
async function collectFalPlanImages(payload, plan5, ctx, req) {
|
|
12356
|
+
const files = filesOf(payload, plan5);
|
|
12228
12357
|
if (files.length === 0) {
|
|
12229
|
-
throw fail2(ctx.model.id, `fal ${
|
|
12358
|
+
throw fail2(ctx.model.id, `fal ${plan5.endpoint} returned no image`, "provider_rejected");
|
|
12230
12359
|
}
|
|
12231
12360
|
const images = await Promise.all(
|
|
12232
12361
|
files.map(async (file) => {
|
|
@@ -12241,18 +12370,18 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
|
|
|
12241
12370
|
unit: "images",
|
|
12242
12371
|
quantity: images.length
|
|
12243
12372
|
};
|
|
12244
|
-
const billedSize =
|
|
12373
|
+
const billedSize = plan5.imageSize ?? req.size;
|
|
12245
12374
|
if (billedSize !== void 0 && ctx.model.type === "image") usage6.imageSize = billedSize;
|
|
12246
|
-
if (
|
|
12375
|
+
if (plan5.imageQuality !== void 0) usage6.imageQuality = plan5.imageQuality;
|
|
12247
12376
|
const result = { images, usage: usage6, raw: payload };
|
|
12248
12377
|
const remote = files.find((f) => !f.url.startsWith("data:"));
|
|
12249
12378
|
if (remote !== void 0) result.outputUrl = remote.url;
|
|
12250
12379
|
return result;
|
|
12251
12380
|
}
|
|
12252
12381
|
async function generateFalFamilyImage(req, ctx, run) {
|
|
12253
|
-
const
|
|
12254
|
-
const payload = await run(
|
|
12255
|
-
return collectFalPlanImages(payload,
|
|
12382
|
+
const plan5 = planFalImage(req, ctx.model.providerModelId, ctx.model.id);
|
|
12383
|
+
const payload = await run(plan5.endpoint, plan5.input);
|
|
12384
|
+
return collectFalPlanImages(payload, plan5, ctx, req);
|
|
12256
12385
|
}
|
|
12257
12386
|
|
|
12258
12387
|
// src/adapters/fal-mask.ts
|
|
@@ -13212,6 +13341,39 @@ function inputLengthSeconds(req, input) {
|
|
|
13212
13341
|
return (payload) => reportedSeconds2(payload) ?? input?.durationSeconds ?? req.durationSeconds ?? 5;
|
|
13213
13342
|
}
|
|
13214
13343
|
|
|
13344
|
+
// src/adapters/fal-avatar.ts
|
|
13345
|
+
var ENDPOINTS = /* @__PURE__ */ new Map([
|
|
13346
|
+
["heygen/avatar-6/image-to-video", { promptField: "motion_prompt", resolution: true }],
|
|
13347
|
+
["heygen/avatar-6/turbo/image-to-video", { promptField: "motion_prompt", resolution: true }],
|
|
13348
|
+
["fal-ai/kling-video/ai-avatar/v2/standard", { promptField: "prompt", resolution: false }],
|
|
13349
|
+
["fal-ai/kling-video/ai-avatar/v2/pro", { promptField: "prompt", resolution: false }],
|
|
13350
|
+
["veed/fabric-1.0", { resolution: true }],
|
|
13351
|
+
["veed/fabric-1.0/fast", { resolution: true }],
|
|
13352
|
+
["fal-ai/sync-lipsync/v3/image-to-video", { resolution: false }]
|
|
13353
|
+
]);
|
|
13354
|
+
function plan(req, ctx) {
|
|
13355
|
+
const id = ctx.model.providerModelId.toLowerCase();
|
|
13356
|
+
const endpoint = ENDPOINTS.get(id);
|
|
13357
|
+
const [image] = req.referenceImages ?? [];
|
|
13358
|
+
const [audio] = req.referenceAudios ?? [];
|
|
13359
|
+
if (endpoint === void 0 || image === void 0 || audio === void 0) {
|
|
13360
|
+
throw refusal2(ctx, "needs one image and one audio clip", "missing_input");
|
|
13361
|
+
}
|
|
13362
|
+
const input = { image_url: refToUrl(image), audio_url: refToUrl(audio) };
|
|
13363
|
+
const prompt = req.prompt.trim();
|
|
13364
|
+
if (endpoint.promptField !== void 0 && prompt.length > 0) {
|
|
13365
|
+
input[endpoint.promptField] = prompt;
|
|
13366
|
+
}
|
|
13367
|
+
const cap = ctx.model.constraints.references?.audioSeconds?.max;
|
|
13368
|
+
const measured2 = audio.durationSeconds;
|
|
13369
|
+
const seconds3 = (payload) => reportedSeconds2(payload) ?? measured2 ?? cap ?? req.durationSeconds ?? 5;
|
|
13370
|
+
if (!endpoint.resolution) return { endpoint: id, input, seconds: seconds3 };
|
|
13371
|
+
const resolution = resolutionOf2(req, ctx);
|
|
13372
|
+
input["resolution"] = resolution;
|
|
13373
|
+
return { endpoint: id, input, resolution, seconds: seconds3 };
|
|
13374
|
+
}
|
|
13375
|
+
var avatarFamily = { ids: new Set(ENDPOINTS.keys()), plan };
|
|
13376
|
+
|
|
13215
13377
|
// src/adapters/fal-happy-horse.ts
|
|
13216
13378
|
var VIDEO_EDIT = "alibaba/happy-horse/video-edit";
|
|
13217
13379
|
function edit(req, ctx) {
|
|
@@ -13376,7 +13538,7 @@ var klingV4Family = {
|
|
|
13376
13538
|
};
|
|
13377
13539
|
|
|
13378
13540
|
// src/adapters/fal-kling-omni.ts
|
|
13379
|
-
function
|
|
13541
|
+
function plan2(req, ctx) {
|
|
13380
13542
|
const tier = klingTier(req);
|
|
13381
13543
|
const duration = wholeSeconds(req, ctx);
|
|
13382
13544
|
const input = {
|
|
@@ -13411,7 +13573,7 @@ function plan(req, ctx) {
|
|
|
13411
13573
|
}
|
|
13412
13574
|
var klingOmniFamily = {
|
|
13413
13575
|
ids: /* @__PURE__ */ new Set([KLING_O3_OMNI]),
|
|
13414
|
-
plan
|
|
13576
|
+
plan: plan2
|
|
13415
13577
|
};
|
|
13416
13578
|
|
|
13417
13579
|
// src/adapters/fal-minimax-h3.ts
|
|
@@ -13530,7 +13692,7 @@ var minimaxH3MaxFamily = {
|
|
|
13530
13692
|
|
|
13531
13693
|
// src/adapters/fal-omnihuman.ts
|
|
13532
13694
|
var OMNIHUMAN_V22 = "bytedance/omnihuman/v2";
|
|
13533
|
-
function
|
|
13695
|
+
function plan3(req, ctx) {
|
|
13534
13696
|
const [image] = req.referenceImages ?? [];
|
|
13535
13697
|
const [audio] = req.referenceAudios ?? [];
|
|
13536
13698
|
if (image === void 0 || audio === void 0) {
|
|
@@ -13541,14 +13703,14 @@ function plan2(req, ctx) {
|
|
|
13541
13703
|
return { endpoint: OMNIHUMAN_V22, input, seconds: inputLengthSeconds(req, audio) };
|
|
13542
13704
|
}
|
|
13543
13705
|
var OMNIHUMAN_MODEL_IDS = /* @__PURE__ */ new Set([OMNIHUMAN_V22]);
|
|
13544
|
-
var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan:
|
|
13706
|
+
var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan: plan3 };
|
|
13545
13707
|
|
|
13546
13708
|
// src/adapters/fal-vidu.ts
|
|
13547
13709
|
var FAMILY = "fal-ai/vidu/q4";
|
|
13548
13710
|
function viduTier(resolution) {
|
|
13549
13711
|
return resolution === "2k" || resolution === "4k" ? upperTier(resolution) : resolution;
|
|
13550
13712
|
}
|
|
13551
|
-
function
|
|
13713
|
+
function plan4(req, ctx) {
|
|
13552
13714
|
const images = urls(req.referenceImages);
|
|
13553
13715
|
const audios = urls(req.referenceAudios);
|
|
13554
13716
|
const duration = wholeSeconds(req, ctx);
|
|
@@ -13575,7 +13737,7 @@ function plan3(req, ctx) {
|
|
|
13575
13737
|
return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
|
|
13576
13738
|
}
|
|
13577
13739
|
var VIDU_MODEL_IDS = /* @__PURE__ */ new Set([FAMILY]);
|
|
13578
|
-
var viduFamily = { ids: VIDU_MODEL_IDS, plan:
|
|
13740
|
+
var viduFamily = { ids: VIDU_MODEL_IDS, plan: plan4 };
|
|
13579
13741
|
|
|
13580
13742
|
// src/adapters/fal-video-families.ts
|
|
13581
13743
|
var FAMILIES2 = [
|
|
@@ -13585,7 +13747,8 @@ var FAMILIES2 = [
|
|
|
13585
13747
|
minimaxH3MaxFamily,
|
|
13586
13748
|
happyHorseFamily,
|
|
13587
13749
|
viduFamily,
|
|
13588
|
-
omnihumanFamily
|
|
13750
|
+
omnihumanFamily,
|
|
13751
|
+
avatarFamily
|
|
13589
13752
|
];
|
|
13590
13753
|
function isFalFamilyVideo(providerModelId) {
|
|
13591
13754
|
const id = providerModelId.toLowerCase();
|
|
@@ -14016,7 +14179,7 @@ function extractVideoUrl(result, endpoint, model) {
|
|
|
14016
14179
|
}
|
|
14017
14180
|
async function generateFalVideo(req, ctx, deps) {
|
|
14018
14181
|
const providerModelId = ctx.model.providerModelId;
|
|
14019
|
-
const
|
|
14182
|
+
const plan5 = planFalFamilyVideo(req, ctx);
|
|
14020
14183
|
const start = (endpoint2, input, usageOf2) => startFalVideoJob(
|
|
14021
14184
|
ctx,
|
|
14022
14185
|
() => falClientOf(ctx, deps),
|
|
@@ -14024,7 +14187,7 @@ async function generateFalVideo(req, ctx, deps) {
|
|
|
14024
14187
|
input,
|
|
14025
14188
|
videoFileDecoder(ctx, req, endpoint2, usageOf2)
|
|
14026
14189
|
);
|
|
14027
|
-
if (
|
|
14190
|
+
if (plan5 !== void 0) return start(plan5.endpoint, plan5.input, planUsage(ctx, plan5));
|
|
14028
14191
|
if (isKling(providerModelId)) return start(KLING_O1_ENDPOINT, klingO1Input(req));
|
|
14029
14192
|
if (!isMinimax(providerModelId)) {
|
|
14030
14193
|
throw new ModelKitError({
|
|
@@ -14070,9 +14233,9 @@ function videoFileDecoder(ctx, req, endpoint, usageOf2) {
|
|
|
14070
14233
|
raw: payload
|
|
14071
14234
|
});
|
|
14072
14235
|
}
|
|
14073
|
-
function planUsage(ctx,
|
|
14236
|
+
function planUsage(ctx, plan5) {
|
|
14074
14237
|
return (payload) => {
|
|
14075
|
-
const seconds3 =
|
|
14238
|
+
const seconds3 = plan5.seconds(payload);
|
|
14076
14239
|
return {
|
|
14077
14240
|
model: ctx.model.id,
|
|
14078
14241
|
provider: "fal",
|
|
@@ -14080,7 +14243,7 @@ function planUsage(ctx, plan4) {
|
|
|
14080
14243
|
unit: "seconds",
|
|
14081
14244
|
quantity: seconds3,
|
|
14082
14245
|
durationSeconds: seconds3,
|
|
14083
|
-
...
|
|
14246
|
+
...plan5.resolution !== void 0 && { resolution: plan5.resolution }
|
|
14084
14247
|
};
|
|
14085
14248
|
};
|
|
14086
14249
|
}
|
|
@@ -20239,14 +20402,14 @@ function referenceVideoConformPlan(model, probe) {
|
|
|
20239
20402
|
const reasons = [...size?.reasons ?? []];
|
|
20240
20403
|
if (rate) reasons.push(rate.reason);
|
|
20241
20404
|
if (overBytes) reasons.push("bytes_over");
|
|
20242
|
-
const
|
|
20405
|
+
const plan5 = {
|
|
20243
20406
|
width: round(width * scale),
|
|
20244
20407
|
height: round(height * scale),
|
|
20245
20408
|
reasons
|
|
20246
20409
|
};
|
|
20247
|
-
if (rate)
|
|
20248
|
-
if (maxBytes !== void 0)
|
|
20249
|
-
return
|
|
20410
|
+
if (rate) plan5.fps = rate.fps;
|
|
20411
|
+
if (maxBytes !== void 0) plan5.maxBytes = maxBytes;
|
|
20412
|
+
return plan5;
|
|
20250
20413
|
}
|
|
20251
20414
|
function referenceImageConformPlan(model, probe) {
|
|
20252
20415
|
const { width: probedWidth, height: probedHeight } = probe;
|