@shop-os/modelkit 0.26.1 → 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 +18 -0
- package/dist/catalog.cjs +144 -16
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +144 -16
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +213 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +213 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5583,10 +5583,119 @@ var TEXT_MODELS = [
|
|
|
5583
5583
|
})
|
|
5584
5584
|
];
|
|
5585
5585
|
|
|
5586
|
-
// src/catalog/video-
|
|
5587
|
-
var VIDEO_USAGE = { unit: "seconds" };
|
|
5586
|
+
// src/catalog/video-avatars.ts
|
|
5588
5587
|
var MB = 1024 * 1024;
|
|
5589
5588
|
var KLING_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
|
|
5589
|
+
var VEED_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/d540d2bb-0022-4371-8889-48aefaf46bbe.png";
|
|
5590
|
+
var SYNC_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
|
|
5591
|
+
var KIT_AUDIO_CAP_SECONDS = 300;
|
|
5592
|
+
function avatar(row2) {
|
|
5593
|
+
const { min, max, formats, maxBytes } = row2.audio;
|
|
5594
|
+
return {
|
|
5595
|
+
id: row2.id,
|
|
5596
|
+
aliases: row2.aliases,
|
|
5597
|
+
label: row2.label,
|
|
5598
|
+
type: "video",
|
|
5599
|
+
adapter: "fal",
|
|
5600
|
+
providerModelId: row2.providerModelId,
|
|
5601
|
+
lifecycle: "active",
|
|
5602
|
+
exposure: ["cowork", "space_builder"],
|
|
5603
|
+
constraints: {
|
|
5604
|
+
...row2.resolutions !== void 0 && { resolutions: [...row2.resolutions] },
|
|
5605
|
+
references: {
|
|
5606
|
+
images: 1,
|
|
5607
|
+
videos: 0,
|
|
5608
|
+
audios: 1,
|
|
5609
|
+
audioOnly: false,
|
|
5610
|
+
audioSeconds: { ...min !== void 0 && { min }, max },
|
|
5611
|
+
audioFormats: formats,
|
|
5612
|
+
...maxBytes !== void 0 && { audioMaxBytes: maxBytes },
|
|
5613
|
+
min: { images: 1, audios: 1 }
|
|
5614
|
+
},
|
|
5615
|
+
requires: ["references"],
|
|
5616
|
+
supports: [],
|
|
5617
|
+
...row2.promptMaxChars === void 0 ? { noPrompt: true } : { prompt: { referenceSyntax: "descriptive", maxChars: row2.promptMaxChars } },
|
|
5618
|
+
audio: "always"
|
|
5619
|
+
},
|
|
5620
|
+
defaults: row2.resolutions === void 0 ? {} : { resolution: row2.resolutions[0] },
|
|
5621
|
+
usage: { unit: "seconds" },
|
|
5622
|
+
pricingKind: "video_per_second",
|
|
5623
|
+
display: {
|
|
5624
|
+
provider: row2.provider,
|
|
5625
|
+
...row2.logo !== void 0 && { logo: row2.logo },
|
|
5626
|
+
description: row2.description
|
|
5627
|
+
},
|
|
5628
|
+
capabilities: {}
|
|
5629
|
+
};
|
|
5630
|
+
}
|
|
5631
|
+
function heygenAvatar6(tier) {
|
|
5632
|
+
const turbo2 = tier === "turbo";
|
|
5633
|
+
return avatar({
|
|
5634
|
+
id: turbo2 ? "heygen-avatar-6-turbo" : "heygen-avatar-6",
|
|
5635
|
+
aliases: [],
|
|
5636
|
+
label: turbo2 ? "HeyGen Avatar 6 Turbo" : "HeyGen Avatar 6",
|
|
5637
|
+
providerModelId: turbo2 ? "heygen/avatar-6/turbo/image-to-video" : "heygen/avatar-6/image-to-video",
|
|
5638
|
+
provider: "heygen",
|
|
5639
|
+
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.",
|
|
5640
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"], maxBytes: 50 * MB },
|
|
5641
|
+
resolutions: ["1080p", "2k"],
|
|
5642
|
+
promptMaxChars: 1200
|
|
5643
|
+
});
|
|
5644
|
+
}
|
|
5645
|
+
function klingAvatar(tier) {
|
|
5646
|
+
const label = tier === "pro" ? "Pro" : "Standard";
|
|
5647
|
+
return avatar({
|
|
5648
|
+
id: `kling-ai-avatar-v2-${tier}`,
|
|
5649
|
+
aliases: [],
|
|
5650
|
+
label: `Kling AI Avatar 2.0 ${label}`,
|
|
5651
|
+
providerModelId: `fal-ai/kling-video/ai-avatar/v2/${tier}`,
|
|
5652
|
+
provider: "kuaishou",
|
|
5653
|
+
logo: KLING_LOGO,
|
|
5654
|
+
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.`,
|
|
5655
|
+
audio: { min: 2, max: 300, formats: ["mp3", "wav", "m4a", "aac"], maxBytes: 5 * MB },
|
|
5656
|
+
promptMaxChars: 2500
|
|
5657
|
+
});
|
|
5658
|
+
}
|
|
5659
|
+
function veedFabric(tier) {
|
|
5660
|
+
const fast = tier === "fast";
|
|
5661
|
+
return avatar({
|
|
5662
|
+
id: fast ? "veed-fabric-1.0-fast" : "veed-fabric-1.0",
|
|
5663
|
+
aliases: [fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0"],
|
|
5664
|
+
label: fast ? "VEED Fabric 1.0 Fast" : "VEED Fabric 1.0",
|
|
5665
|
+
providerModelId: fast ? "veed/fabric-1.0/fast" : "veed/fabric-1.0",
|
|
5666
|
+
provider: "veed",
|
|
5667
|
+
logo: VEED_LOGO,
|
|
5668
|
+
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.",
|
|
5669
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["mp3", "ogg", "wav", "m4a", "aac"] },
|
|
5670
|
+
resolutions: ["720p", "480p"]
|
|
5671
|
+
});
|
|
5672
|
+
}
|
|
5673
|
+
var VIDEO_AVATAR_MODELS = [
|
|
5674
|
+
heygenAvatar6("regular"),
|
|
5675
|
+
heygenAvatar6("turbo"),
|
|
5676
|
+
klingAvatar("standard"),
|
|
5677
|
+
klingAvatar("pro"),
|
|
5678
|
+
veedFabric("regular"),
|
|
5679
|
+
veedFabric("fast"),
|
|
5680
|
+
// https://fal.ai/models/fal-ai/sync-lipsync/v3/image-to-video/api: image_url and audio_url
|
|
5681
|
+
// only; the video matches the audio's length. sync takes WAV or MP3
|
|
5682
|
+
// (https://sync.so/docs/quickstart); the length is the kit cap.
|
|
5683
|
+
avatar({
|
|
5684
|
+
id: "sync-3-image-to-video",
|
|
5685
|
+
aliases: ["fal-ai/sync-lipsync/v3/image-to-video"],
|
|
5686
|
+
label: "Sync 3 Avatar",
|
|
5687
|
+
providerModelId: "fal-ai/sync-lipsync/v3/image-to-video",
|
|
5688
|
+
provider: "sync",
|
|
5689
|
+
logo: SYNC_LOGO2,
|
|
5690
|
+
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.",
|
|
5691
|
+
audio: { max: KIT_AUDIO_CAP_SECONDS, formats: ["wav", "mp3"] }
|
|
5692
|
+
})
|
|
5693
|
+
];
|
|
5694
|
+
|
|
5695
|
+
// src/catalog/video-families.ts
|
|
5696
|
+
var VIDEO_USAGE = { unit: "seconds" };
|
|
5697
|
+
var MB2 = 1024 * 1024;
|
|
5698
|
+
var KLING_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
|
|
5590
5699
|
var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
5591
5700
|
var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
5592
5701
|
var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
|
|
@@ -5644,7 +5753,7 @@ function klingMotionControl(tier) {
|
|
|
5644
5753
|
pricingKind: "video_per_second",
|
|
5645
5754
|
display: {
|
|
5646
5755
|
provider: "kuaishou",
|
|
5647
|
-
logo:
|
|
5756
|
+
logo: KLING_LOGO2,
|
|
5648
5757
|
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.`
|
|
5649
5758
|
},
|
|
5650
5759
|
capabilities: {}
|
|
@@ -5677,7 +5786,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5677
5786
|
pricingKind: "video_per_second",
|
|
5678
5787
|
display: {
|
|
5679
5788
|
provider: "kuaishou",
|
|
5680
|
-
logo:
|
|
5789
|
+
logo: KLING_LOGO2,
|
|
5681
5790
|
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."
|
|
5682
5791
|
},
|
|
5683
5792
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
@@ -5708,7 +5817,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5708
5817
|
pricingKind: "video_per_second",
|
|
5709
5818
|
display: {
|
|
5710
5819
|
provider: "kuaishou",
|
|
5711
|
-
logo:
|
|
5820
|
+
logo: KLING_LOGO2,
|
|
5712
5821
|
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."
|
|
5713
5822
|
},
|
|
5714
5823
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5752,7 +5861,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5752
5861
|
pricingKind: "video_per_second",
|
|
5753
5862
|
display: {
|
|
5754
5863
|
provider: "kuaishou",
|
|
5755
|
-
logo:
|
|
5864
|
+
logo: KLING_LOGO2,
|
|
5756
5865
|
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."
|
|
5757
5866
|
},
|
|
5758
5867
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
@@ -5786,7 +5895,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5786
5895
|
pricingKind: "video_per_second",
|
|
5787
5896
|
display: {
|
|
5788
5897
|
provider: "kuaishou",
|
|
5789
|
-
logo:
|
|
5898
|
+
logo: KLING_LOGO2,
|
|
5790
5899
|
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."
|
|
5791
5900
|
},
|
|
5792
5901
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5827,7 +5936,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5827
5936
|
pricingKind: "video_per_second",
|
|
5828
5937
|
display: {
|
|
5829
5938
|
provider: "kuaishou",
|
|
5830
|
-
logo:
|
|
5939
|
+
logo: KLING_LOGO2,
|
|
5831
5940
|
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."
|
|
5832
5941
|
}
|
|
5833
5942
|
},
|
|
@@ -5867,7 +5976,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5867
5976
|
pricingKind: "video_per_second",
|
|
5868
5977
|
display: {
|
|
5869
5978
|
provider: "kuaishou",
|
|
5870
|
-
logo:
|
|
5979
|
+
logo: KLING_LOGO2,
|
|
5871
5980
|
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."
|
|
5872
5981
|
},
|
|
5873
5982
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5894,7 +6003,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5894
6003
|
...NO_REFERENCES,
|
|
5895
6004
|
audios: 1,
|
|
5896
6005
|
audioSeconds: { min: 2 },
|
|
5897
|
-
audioMaxBytes: 15 *
|
|
6006
|
+
audioMaxBytes: 15 * MB2
|
|
5898
6007
|
},
|
|
5899
6008
|
supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
|
|
5900
6009
|
prompt: H3_PROMPT,
|
|
@@ -6093,7 +6202,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
6093
6202
|
audioOnly: false,
|
|
6094
6203
|
audioSeconds: { min: 3, max: 12 },
|
|
6095
6204
|
audioFormats: ["mp3"],
|
|
6096
|
-
audioMaxBytes: 50 *
|
|
6205
|
+
audioMaxBytes: 50 * MB2
|
|
6097
6206
|
},
|
|
6098
6207
|
// Sound (dialogue and effects) is a reference-to-video option; image-to-video is silent.
|
|
6099
6208
|
supports: ["seed", "generateAudio", "safetyChecker"],
|
|
@@ -6134,7 +6243,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
6134
6243
|
audioOnly: false,
|
|
6135
6244
|
audioSeconds: { min: 4, max: 300 },
|
|
6136
6245
|
audioFormats: ["wav", "mp3"],
|
|
6137
|
-
audioMaxBytes: 15 *
|
|
6246
|
+
audioMaxBytes: 15 * MB2,
|
|
6138
6247
|
min: { images: 1, audios: 1 }
|
|
6139
6248
|
},
|
|
6140
6249
|
requires: ["references"],
|
|
@@ -7237,6 +7346,7 @@ var VIDEO_MODELS = [
|
|
|
7237
7346
|
capabilities: {}
|
|
7238
7347
|
},
|
|
7239
7348
|
...VIDEO_FAMILY_MODELS,
|
|
7349
|
+
...VIDEO_AVATAR_MODELS,
|
|
7240
7350
|
...LUMA_VIDEO_MODELS
|
|
7241
7351
|
];
|
|
7242
7352
|
|
|
@@ -10251,6 +10361,15 @@ var KLING_O3_IMAGE_CAP = 7;
|
|
|
10251
10361
|
var KLING_V4_IMAGE_CAP = 10;
|
|
10252
10362
|
var TURBO_AUDIO_MIN_SECONDS = 2;
|
|
10253
10363
|
var OMNIHUMAN_AUDIO_SECONDS = { min: 4, max: 300 };
|
|
10364
|
+
var AVATAR_AUDIO = [
|
|
10365
|
+
["heygen/avatar-6/image-to-video", { max: 300 }],
|
|
10366
|
+
["heygen/avatar-6/turbo/image-to-video", { max: 300 }],
|
|
10367
|
+
["fal-ai/kling-video/ai-avatar/v2/standard", { min: 2, max: 300 }],
|
|
10368
|
+
["fal-ai/kling-video/ai-avatar/v2/pro", { min: 2, max: 300 }],
|
|
10369
|
+
["veed/fabric-1.0", { max: 300, urlOnly: true }],
|
|
10370
|
+
["veed/fabric-1.0/fast", { max: 300, urlOnly: true }],
|
|
10371
|
+
["fal-ai/sync-lipsync/v3/image-to-video", { max: 300, urlOnly: true }]
|
|
10372
|
+
];
|
|
10254
10373
|
function missing(message) {
|
|
10255
10374
|
return { code: "missing_input", message };
|
|
10256
10375
|
}
|
|
@@ -10384,7 +10503,10 @@ function viduQ4(req) {
|
|
|
10384
10503
|
}
|
|
10385
10504
|
return req.firstFrame === void 0 ? missing("needs a start frame or reference images") : void 0;
|
|
10386
10505
|
}
|
|
10387
|
-
function
|
|
10506
|
+
function isPublicUrl(ref) {
|
|
10507
|
+
return "url" in ref && !ref.url.startsWith("data:");
|
|
10508
|
+
}
|
|
10509
|
+
function imageAndAudio(req, audioSeconds) {
|
|
10388
10510
|
const frames = noFrames(req);
|
|
10389
10511
|
if (frames !== void 0) return frames;
|
|
10390
10512
|
if (count(req.referenceVideos) > 0) return unsupported3("takes no reference videos");
|
|
@@ -10396,9 +10518,12 @@ function omnihuman(req) {
|
|
|
10396
10518
|
if (extraImages.length > 0 || extraAudios.length > 0) {
|
|
10397
10519
|
return unsupported3("takes exactly one image and one audio clip");
|
|
10398
10520
|
}
|
|
10399
|
-
|
|
10521
|
+
if (audioSeconds.urlOnly === true && !(isPublicUrl(image) && isPublicUrl(audio))) {
|
|
10522
|
+
return unsupported3("takes its image and audio as public URLs, not inline bytes");
|
|
10523
|
+
}
|
|
10524
|
+
return inputSeconds("audio", audio, audioSeconds);
|
|
10400
10525
|
}
|
|
10401
|
-
var RULES =
|
|
10526
|
+
var RULES = new Map([
|
|
10402
10527
|
[MOTION_PRO, motionControl],
|
|
10403
10528
|
[MOTION_STANDARD, motionControl],
|
|
10404
10529
|
[O3_REFERENCE, o3Reference],
|
|
@@ -10415,7 +10540,10 @@ var RULES = /* @__PURE__ */ new Map([
|
|
|
10415
10540
|
[HAPPY_HORSE, happyHorse],
|
|
10416
10541
|
[HAPPY_HORSE_EDIT, happyHorseEdit],
|
|
10417
10542
|
[VIDU_Q4, viduQ4],
|
|
10418
|
-
[OMNIHUMAN_V2,
|
|
10543
|
+
[OMNIHUMAN_V2, (req) => imageAndAudio(req, OMNIHUMAN_AUDIO_SECONDS)],
|
|
10544
|
+
...AVATAR_AUDIO.map(
|
|
10545
|
+
([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
|
|
10546
|
+
)
|
|
10419
10547
|
]);
|
|
10420
10548
|
function falVideoProblem(providerModelId, req) {
|
|
10421
10549
|
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
@@ -11992,11 +12120,11 @@ function toolInput(ctx, req, output) {
|
|
|
11992
12120
|
}
|
|
11993
12121
|
var EXR_DEFAULT_PROMPT = "The same video in high dynamic range, with unchanged content, motion, framing and timing.";
|
|
11994
12122
|
async function submitFalVideoTool(req, ctx, opts) {
|
|
11995
|
-
const
|
|
11996
|
-
if (!
|
|
12123
|
+
const plan5 = planVideoTool(ctx.model, req);
|
|
12124
|
+
if (!plan5.ok) {
|
|
11997
12125
|
throw new ModelKitError({
|
|
11998
12126
|
code: "unsupported_option",
|
|
11999
|
-
message:
|
|
12127
|
+
message: plan5.error,
|
|
12000
12128
|
provider: "fal",
|
|
12001
12129
|
model: ctx.model.id,
|
|
12002
12130
|
retryable: false
|
|
@@ -12004,7 +12132,7 @@ async function submitFalVideoTool(req, ctx, opts) {
|
|
|
12004
12132
|
}
|
|
12005
12133
|
const target = new URL(`${FAL_QUEUE_ORIGIN}/${ctx.model.providerModelId}`);
|
|
12006
12134
|
if (opts.webhookUrl !== void 0) target.searchParams.set("fal_webhook", opts.webhookUrl);
|
|
12007
|
-
const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req,
|
|
12135
|
+
const res = await queueFetch(ctx, target.toString(), "POST", toolInput(ctx, req, plan5.output));
|
|
12008
12136
|
const parsed = submitResponseSchema.safeParse(await readJson(ctx, res));
|
|
12009
12137
|
if (!parsed.success) {
|
|
12010
12138
|
throw new ModelKitError({
|
|
@@ -12022,7 +12150,7 @@ async function submitFalVideoTool(req, ctx, opts) {
|
|
|
12022
12150
|
statusUrl: parsed.data.status_url,
|
|
12023
12151
|
responseUrl: parsed.data.response_url,
|
|
12024
12152
|
cancelUrl: parsed.data.cancel_url,
|
|
12025
|
-
output:
|
|
12153
|
+
output: plan5.output
|
|
12026
12154
|
};
|
|
12027
12155
|
}
|
|
12028
12156
|
async function falVideoToolStatus(sub, ctx) {
|
|
@@ -12344,14 +12472,14 @@ function planFalImage(req, providerModelId, model) {
|
|
|
12344
12472
|
const exact = falExactSize(spec, req);
|
|
12345
12473
|
const call = { label: spec.label, req, refs, edit: edit2, ...exact !== void 0 && { exact } };
|
|
12346
12474
|
const built = family.build(call, model);
|
|
12347
|
-
const
|
|
12475
|
+
const plan5 = {
|
|
12348
12476
|
endpoint: edit2 && family.editEndpoint !== void 0 ? family.editEndpoint : id,
|
|
12349
12477
|
input: built.input,
|
|
12350
12478
|
output: family.output ?? "images"
|
|
12351
12479
|
};
|
|
12352
|
-
if (built.imageQuality !== void 0)
|
|
12353
|
-
if (built.imageSize !== void 0)
|
|
12354
|
-
return
|
|
12480
|
+
if (built.imageQuality !== void 0) plan5.imageQuality = built.imageQuality;
|
|
12481
|
+
if (built.imageSize !== void 0) plan5.imageSize = built.imageSize;
|
|
12482
|
+
return plan5;
|
|
12355
12483
|
}
|
|
12356
12484
|
var FalFileSchema = import_zod17.z.object({ url: import_zod17.z.string(), content_type: import_zod17.z.string().nullish() });
|
|
12357
12485
|
var ImagesPayloadSchema = import_zod17.z.object({ images: import_zod17.z.array(FalFileSchema) });
|
|
@@ -12373,18 +12501,18 @@ async function downloadFalFile(ctx, file) {
|
|
|
12373
12501
|
const mime = res.headers.get("content-type") ?? file.content_type ?? "";
|
|
12374
12502
|
return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
|
|
12375
12503
|
}
|
|
12376
|
-
function filesOf(payload,
|
|
12377
|
-
if (
|
|
12504
|
+
function filesOf(payload, plan5) {
|
|
12505
|
+
if (plan5.output === "image") {
|
|
12378
12506
|
const parsed2 = ImagePayloadSchema.safeParse(payload);
|
|
12379
12507
|
return parsed2.success ? [parsed2.data.image] : [];
|
|
12380
12508
|
}
|
|
12381
12509
|
const parsed = ImagesPayloadSchema.safeParse(payload);
|
|
12382
12510
|
return parsed.success ? parsed.data.images : [];
|
|
12383
12511
|
}
|
|
12384
|
-
async function collectFalPlanImages(payload,
|
|
12385
|
-
const files = filesOf(payload,
|
|
12512
|
+
async function collectFalPlanImages(payload, plan5, ctx, req) {
|
|
12513
|
+
const files = filesOf(payload, plan5);
|
|
12386
12514
|
if (files.length === 0) {
|
|
12387
|
-
throw fail2(ctx.model.id, `fal ${
|
|
12515
|
+
throw fail2(ctx.model.id, `fal ${plan5.endpoint} returned no image`, "provider_rejected");
|
|
12388
12516
|
}
|
|
12389
12517
|
const images = await Promise.all(
|
|
12390
12518
|
files.map(async (file) => {
|
|
@@ -12399,18 +12527,18 @@ async function collectFalPlanImages(payload, plan4, ctx, req) {
|
|
|
12399
12527
|
unit: "images",
|
|
12400
12528
|
quantity: images.length
|
|
12401
12529
|
};
|
|
12402
|
-
const billedSize =
|
|
12530
|
+
const billedSize = plan5.imageSize ?? req.size;
|
|
12403
12531
|
if (billedSize !== void 0 && ctx.model.type === "image") usage6.imageSize = billedSize;
|
|
12404
|
-
if (
|
|
12532
|
+
if (plan5.imageQuality !== void 0) usage6.imageQuality = plan5.imageQuality;
|
|
12405
12533
|
const result = { images, usage: usage6, raw: payload };
|
|
12406
12534
|
const remote = files.find((f) => !f.url.startsWith("data:"));
|
|
12407
12535
|
if (remote !== void 0) result.outputUrl = remote.url;
|
|
12408
12536
|
return result;
|
|
12409
12537
|
}
|
|
12410
12538
|
async function generateFalFamilyImage(req, ctx, run) {
|
|
12411
|
-
const
|
|
12412
|
-
const payload = await run(
|
|
12413
|
-
return collectFalPlanImages(payload,
|
|
12539
|
+
const plan5 = planFalImage(req, ctx.model.providerModelId, ctx.model.id);
|
|
12540
|
+
const payload = await run(plan5.endpoint, plan5.input);
|
|
12541
|
+
return collectFalPlanImages(payload, plan5, ctx, req);
|
|
12414
12542
|
}
|
|
12415
12543
|
|
|
12416
12544
|
// src/adapters/fal-mask.ts
|
|
@@ -13370,6 +13498,39 @@ function inputLengthSeconds(req, input) {
|
|
|
13370
13498
|
return (payload) => reportedSeconds2(payload) ?? input?.durationSeconds ?? req.durationSeconds ?? 5;
|
|
13371
13499
|
}
|
|
13372
13500
|
|
|
13501
|
+
// src/adapters/fal-avatar.ts
|
|
13502
|
+
var ENDPOINTS = /* @__PURE__ */ new Map([
|
|
13503
|
+
["heygen/avatar-6/image-to-video", { promptField: "motion_prompt", resolution: true }],
|
|
13504
|
+
["heygen/avatar-6/turbo/image-to-video", { promptField: "motion_prompt", resolution: true }],
|
|
13505
|
+
["fal-ai/kling-video/ai-avatar/v2/standard", { promptField: "prompt", resolution: false }],
|
|
13506
|
+
["fal-ai/kling-video/ai-avatar/v2/pro", { promptField: "prompt", resolution: false }],
|
|
13507
|
+
["veed/fabric-1.0", { resolution: true }],
|
|
13508
|
+
["veed/fabric-1.0/fast", { resolution: true }],
|
|
13509
|
+
["fal-ai/sync-lipsync/v3/image-to-video", { resolution: false }]
|
|
13510
|
+
]);
|
|
13511
|
+
function plan(req, ctx) {
|
|
13512
|
+
const id = ctx.model.providerModelId.toLowerCase();
|
|
13513
|
+
const endpoint = ENDPOINTS.get(id);
|
|
13514
|
+
const [image] = req.referenceImages ?? [];
|
|
13515
|
+
const [audio] = req.referenceAudios ?? [];
|
|
13516
|
+
if (endpoint === void 0 || image === void 0 || audio === void 0) {
|
|
13517
|
+
throw refusal2(ctx, "needs one image and one audio clip", "missing_input");
|
|
13518
|
+
}
|
|
13519
|
+
const input = { image_url: refToUrl(image), audio_url: refToUrl(audio) };
|
|
13520
|
+
const prompt = req.prompt.trim();
|
|
13521
|
+
if (endpoint.promptField !== void 0 && prompt.length > 0) {
|
|
13522
|
+
input[endpoint.promptField] = prompt;
|
|
13523
|
+
}
|
|
13524
|
+
const cap = ctx.model.constraints.references?.audioSeconds?.max;
|
|
13525
|
+
const measured2 = audio.durationSeconds;
|
|
13526
|
+
const seconds3 = (payload) => reportedSeconds2(payload) ?? measured2 ?? cap ?? req.durationSeconds ?? 5;
|
|
13527
|
+
if (!endpoint.resolution) return { endpoint: id, input, seconds: seconds3 };
|
|
13528
|
+
const resolution = resolutionOf2(req, ctx);
|
|
13529
|
+
input["resolution"] = resolution;
|
|
13530
|
+
return { endpoint: id, input, resolution, seconds: seconds3 };
|
|
13531
|
+
}
|
|
13532
|
+
var avatarFamily = { ids: new Set(ENDPOINTS.keys()), plan };
|
|
13533
|
+
|
|
13373
13534
|
// src/adapters/fal-happy-horse.ts
|
|
13374
13535
|
var VIDEO_EDIT = "alibaba/happy-horse/video-edit";
|
|
13375
13536
|
function edit(req, ctx) {
|
|
@@ -13534,7 +13695,7 @@ var klingV4Family = {
|
|
|
13534
13695
|
};
|
|
13535
13696
|
|
|
13536
13697
|
// src/adapters/fal-kling-omni.ts
|
|
13537
|
-
function
|
|
13698
|
+
function plan2(req, ctx) {
|
|
13538
13699
|
const tier = klingTier(req);
|
|
13539
13700
|
const duration = wholeSeconds(req, ctx);
|
|
13540
13701
|
const input = {
|
|
@@ -13569,7 +13730,7 @@ function plan(req, ctx) {
|
|
|
13569
13730
|
}
|
|
13570
13731
|
var klingOmniFamily = {
|
|
13571
13732
|
ids: /* @__PURE__ */ new Set([KLING_O3_OMNI]),
|
|
13572
|
-
plan
|
|
13733
|
+
plan: plan2
|
|
13573
13734
|
};
|
|
13574
13735
|
|
|
13575
13736
|
// src/adapters/fal-minimax-h3.ts
|
|
@@ -13688,7 +13849,7 @@ var minimaxH3MaxFamily = {
|
|
|
13688
13849
|
|
|
13689
13850
|
// src/adapters/fal-omnihuman.ts
|
|
13690
13851
|
var OMNIHUMAN_V22 = "bytedance/omnihuman/v2";
|
|
13691
|
-
function
|
|
13852
|
+
function plan3(req, ctx) {
|
|
13692
13853
|
const [image] = req.referenceImages ?? [];
|
|
13693
13854
|
const [audio] = req.referenceAudios ?? [];
|
|
13694
13855
|
if (image === void 0 || audio === void 0) {
|
|
@@ -13699,14 +13860,14 @@ function plan2(req, ctx) {
|
|
|
13699
13860
|
return { endpoint: OMNIHUMAN_V22, input, seconds: inputLengthSeconds(req, audio) };
|
|
13700
13861
|
}
|
|
13701
13862
|
var OMNIHUMAN_MODEL_IDS = /* @__PURE__ */ new Set([OMNIHUMAN_V22]);
|
|
13702
|
-
var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan:
|
|
13863
|
+
var omnihumanFamily = { ids: OMNIHUMAN_MODEL_IDS, plan: plan3 };
|
|
13703
13864
|
|
|
13704
13865
|
// src/adapters/fal-vidu.ts
|
|
13705
13866
|
var FAMILY = "fal-ai/vidu/q4";
|
|
13706
13867
|
function viduTier(resolution) {
|
|
13707
13868
|
return resolution === "2k" || resolution === "4k" ? upperTier(resolution) : resolution;
|
|
13708
13869
|
}
|
|
13709
|
-
function
|
|
13870
|
+
function plan4(req, ctx) {
|
|
13710
13871
|
const images = urls(req.referenceImages);
|
|
13711
13872
|
const audios = urls(req.referenceAudios);
|
|
13712
13873
|
const duration = wholeSeconds(req, ctx);
|
|
@@ -13733,7 +13894,7 @@ function plan3(req, ctx) {
|
|
|
13733
13894
|
return { endpoint, input, resolution, seconds: requestedSeconds(duration) };
|
|
13734
13895
|
}
|
|
13735
13896
|
var VIDU_MODEL_IDS = /* @__PURE__ */ new Set([FAMILY]);
|
|
13736
|
-
var viduFamily = { ids: VIDU_MODEL_IDS, plan:
|
|
13897
|
+
var viduFamily = { ids: VIDU_MODEL_IDS, plan: plan4 };
|
|
13737
13898
|
|
|
13738
13899
|
// src/adapters/fal-video-families.ts
|
|
13739
13900
|
var FAMILIES2 = [
|
|
@@ -13743,7 +13904,8 @@ var FAMILIES2 = [
|
|
|
13743
13904
|
minimaxH3MaxFamily,
|
|
13744
13905
|
happyHorseFamily,
|
|
13745
13906
|
viduFamily,
|
|
13746
|
-
omnihumanFamily
|
|
13907
|
+
omnihumanFamily,
|
|
13908
|
+
avatarFamily
|
|
13747
13909
|
];
|
|
13748
13910
|
function isFalFamilyVideo(providerModelId) {
|
|
13749
13911
|
const id = providerModelId.toLowerCase();
|
|
@@ -14174,7 +14336,7 @@ function extractVideoUrl(result, endpoint, model) {
|
|
|
14174
14336
|
}
|
|
14175
14337
|
async function generateFalVideo(req, ctx, deps) {
|
|
14176
14338
|
const providerModelId = ctx.model.providerModelId;
|
|
14177
|
-
const
|
|
14339
|
+
const plan5 = planFalFamilyVideo(req, ctx);
|
|
14178
14340
|
const start = (endpoint2, input, usageOf2) => startFalVideoJob(
|
|
14179
14341
|
ctx,
|
|
14180
14342
|
() => falClientOf(ctx, deps),
|
|
@@ -14182,7 +14344,7 @@ async function generateFalVideo(req, ctx, deps) {
|
|
|
14182
14344
|
input,
|
|
14183
14345
|
videoFileDecoder(ctx, req, endpoint2, usageOf2)
|
|
14184
14346
|
);
|
|
14185
|
-
if (
|
|
14347
|
+
if (plan5 !== void 0) return start(plan5.endpoint, plan5.input, planUsage(ctx, plan5));
|
|
14186
14348
|
if (isKling(providerModelId)) return start(KLING_O1_ENDPOINT, klingO1Input(req));
|
|
14187
14349
|
if (!isMinimax(providerModelId)) {
|
|
14188
14350
|
throw new ModelKitError({
|
|
@@ -14228,9 +14390,9 @@ function videoFileDecoder(ctx, req, endpoint, usageOf2) {
|
|
|
14228
14390
|
raw: payload
|
|
14229
14391
|
});
|
|
14230
14392
|
}
|
|
14231
|
-
function planUsage(ctx,
|
|
14393
|
+
function planUsage(ctx, plan5) {
|
|
14232
14394
|
return (payload) => {
|
|
14233
|
-
const seconds3 =
|
|
14395
|
+
const seconds3 = plan5.seconds(payload);
|
|
14234
14396
|
return {
|
|
14235
14397
|
model: ctx.model.id,
|
|
14236
14398
|
provider: "fal",
|
|
@@ -14238,7 +14400,7 @@ function planUsage(ctx, plan4) {
|
|
|
14238
14400
|
unit: "seconds",
|
|
14239
14401
|
quantity: seconds3,
|
|
14240
14402
|
durationSeconds: seconds3,
|
|
14241
|
-
...
|
|
14403
|
+
...plan5.resolution !== void 0 && { resolution: plan5.resolution }
|
|
14242
14404
|
};
|
|
14243
14405
|
};
|
|
14244
14406
|
}
|
|
@@ -20395,14 +20557,14 @@ function referenceVideoConformPlan(model, probe) {
|
|
|
20395
20557
|
const reasons = [...size?.reasons ?? []];
|
|
20396
20558
|
if (rate) reasons.push(rate.reason);
|
|
20397
20559
|
if (overBytes) reasons.push("bytes_over");
|
|
20398
|
-
const
|
|
20560
|
+
const plan5 = {
|
|
20399
20561
|
width: round(width * scale),
|
|
20400
20562
|
height: round(height * scale),
|
|
20401
20563
|
reasons
|
|
20402
20564
|
};
|
|
20403
|
-
if (rate)
|
|
20404
|
-
if (maxBytes !== void 0)
|
|
20405
|
-
return
|
|
20565
|
+
if (rate) plan5.fps = rate.fps;
|
|
20566
|
+
if (maxBytes !== void 0) plan5.maxBytes = maxBytes;
|
|
20567
|
+
return plan5;
|
|
20406
20568
|
}
|
|
20407
20569
|
function referenceImageConformPlan(model, probe) {
|
|
20408
20570
|
const { width: probedWidth, height: probedHeight } = probe;
|