@shop-os/modelkit 0.2.14 → 0.2.16
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 +143 -15
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +79 -3
- package/dist/catalog.d.ts +79 -3
- package/dist/catalog.js +143 -15
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +203 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -3
- package/dist/index.d.ts +79 -3
- package/dist/index.js +202 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -104,6 +104,7 @@ __export(index_exports, {
|
|
|
104
104
|
textUsageEvent: () => textUsageEvent,
|
|
105
105
|
toGeneratedImage: () => toGeneratedImage,
|
|
106
106
|
validateInputSpec: () => validateInputSpec,
|
|
107
|
+
videoLengthViolation: () => videoLengthViolation,
|
|
107
108
|
withRetry: () => withRetry,
|
|
108
109
|
xaiVideoAdapter: () => xaiVideoAdapter
|
|
109
110
|
});
|
|
@@ -1482,7 +1483,8 @@ var VIDEO_MODELS = [
|
|
|
1482
1483
|
// reference clip keeps its own framing.
|
|
1483
1484
|
aspectRatios: [...OMNI_RATIOS],
|
|
1484
1485
|
durations: [3, 4, 5, 6, 7, 8, 9, 10],
|
|
1485
|
-
references: { images: 6, videos: 1 },
|
|
1486
|
+
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
1487
|
+
sourceVideoSeconds: { max: 10 },
|
|
1486
1488
|
supports: []
|
|
1487
1489
|
},
|
|
1488
1490
|
defaults: {},
|
|
@@ -1508,8 +1510,16 @@ var VIDEO_MODELS = [
|
|
|
1508
1510
|
aspectRatios: [...OMNI_RATIOS],
|
|
1509
1511
|
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
1510
1512
|
durations: [3, 4, 5, 6, 7, 8, 9, 10],
|
|
1511
|
-
references: { images: 6, videos: 1 },
|
|
1512
|
-
|
|
1513
|
+
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
1514
|
+
sourceVideoSeconds: { max: 10 },
|
|
1515
|
+
// Extension (probe 2026-09-24, 360p): each `taskType: "extend"` call
|
|
1516
|
+
// renders `durationSeconds` more and returns the FULL cumulative clip
|
|
1517
|
+
// (3 s -> 6 s -> 9 s); the provider caps the clip at 40 s. A first
|
|
1518
|
+
// extension can upload a <= 10 s source with task "extend"; later ones
|
|
1519
|
+
// chain by `previousInteractionId` (the API rejects the id together
|
|
1520
|
+
// with a video task, so those calls carry the prompt alone).
|
|
1521
|
+
supports: ["videoExtension"],
|
|
1522
|
+
extension: { segmentSeconds: 10, maxTotalSeconds: 40 }
|
|
1513
1523
|
},
|
|
1514
1524
|
defaults: {},
|
|
1515
1525
|
usage: { ...VIDEO_USAGE },
|
|
@@ -1517,7 +1527,7 @@ var VIDEO_MODELS = [
|
|
|
1517
1527
|
display: {
|
|
1518
1528
|
provider: "google",
|
|
1519
1529
|
logo: GOOGLE_LOGO2,
|
|
1520
|
-
description: "Google Gemini Omni Flash 1.1 conversational video generation and
|
|
1530
|
+
description: "Google Gemini Omni Flash 1.1 conversational video generation, editing and extension; text, image, and up to 10-second video input, 3-10 second output at up to 4K and 24 FPS, extendable to 40 seconds."
|
|
1521
1531
|
},
|
|
1522
1532
|
capabilities: { acceptsSourceVideo: true }
|
|
1523
1533
|
},
|
|
@@ -1536,7 +1546,14 @@ var VIDEO_MODELS = [
|
|
|
1536
1546
|
resolutions: ["480p", "720p", "1080p", "4k"],
|
|
1537
1547
|
durations: { min: 4, max: 15 },
|
|
1538
1548
|
durationPresets: [4, 6, 8, 10, 12, 15],
|
|
1539
|
-
references: {
|
|
1549
|
+
references: {
|
|
1550
|
+
images: 9,
|
|
1551
|
+
videos: 3,
|
|
1552
|
+
audios: 3,
|
|
1553
|
+
audioOnly: false,
|
|
1554
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1555
|
+
},
|
|
1556
|
+
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
1540
1557
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1541
1558
|
supports: ["generateAudio", "seed", "lastFrame", "watermark"]
|
|
1542
1559
|
},
|
|
@@ -1568,7 +1585,14 @@ var VIDEO_MODELS = [
|
|
|
1568
1585
|
aspectRatios: [...SEEDANCE_RATIOS],
|
|
1569
1586
|
resolutions: ["480p", "720p"],
|
|
1570
1587
|
durations: { min: 4, max: 15 },
|
|
1571
|
-
references: {
|
|
1588
|
+
references: {
|
|
1589
|
+
images: 9,
|
|
1590
|
+
videos: 3,
|
|
1591
|
+
audios: 3,
|
|
1592
|
+
audioOnly: false,
|
|
1593
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1594
|
+
},
|
|
1595
|
+
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
1572
1596
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1573
1597
|
supports: ["generateAudio", "seed", "lastFrame", "watermark"]
|
|
1574
1598
|
},
|
|
@@ -1602,7 +1626,13 @@ var VIDEO_MODELS = [
|
|
|
1602
1626
|
aspectRatios: [...SEEDANCE_RATIOS],
|
|
1603
1627
|
resolutions: ["480p", "720p", "1080p"],
|
|
1604
1628
|
durations: { min: 4, max: 30 },
|
|
1605
|
-
references: {
|
|
1629
|
+
references: {
|
|
1630
|
+
images: 30,
|
|
1631
|
+
videos: 10,
|
|
1632
|
+
audios: 10,
|
|
1633
|
+
videoSeconds: { min: 2, max: 30, total: 30, editMin: 4 }
|
|
1634
|
+
},
|
|
1635
|
+
sourceVideoSeconds: { min: 2, max: 30, editMin: 4, inReferenceTotal: true },
|
|
1606
1636
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1607
1637
|
supports: ["generateAudio", "seed", "lastFrame", "watermark", "taskType"]
|
|
1608
1638
|
},
|
|
@@ -1814,7 +1844,14 @@ var VIDEO_MODELS = [
|
|
|
1814
1844
|
aspectRatios: [...H3_REFERENCE_RATIOS],
|
|
1815
1845
|
resolutions: ["480p", "768p", "2k", "4k"],
|
|
1816
1846
|
durations: { min: 5, max: 15 },
|
|
1817
|
-
references: {
|
|
1847
|
+
references: {
|
|
1848
|
+
images: 9,
|
|
1849
|
+
videos: 3,
|
|
1850
|
+
audios: 3,
|
|
1851
|
+
total: 12,
|
|
1852
|
+
audioOnly: false,
|
|
1853
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1854
|
+
},
|
|
1818
1855
|
supports: ["seed", "promptExpansion", "safetyChecker"]
|
|
1819
1856
|
},
|
|
1820
1857
|
defaults: {
|
|
@@ -1845,7 +1882,14 @@ var VIDEO_MODELS = [
|
|
|
1845
1882
|
aspectRatios: [...H3_REFERENCE_RATIOS],
|
|
1846
1883
|
resolutions: ["480p", "768p"],
|
|
1847
1884
|
durations: { min: 5, max: 15 },
|
|
1848
|
-
references: {
|
|
1885
|
+
references: {
|
|
1886
|
+
images: 9,
|
|
1887
|
+
videos: 3,
|
|
1888
|
+
audios: 3,
|
|
1889
|
+
total: 12,
|
|
1890
|
+
audioOnly: false,
|
|
1891
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1892
|
+
},
|
|
1849
1893
|
supports: ["seed", "promptExpansion", "safetyChecker"]
|
|
1850
1894
|
},
|
|
1851
1895
|
defaults: {
|
|
@@ -1877,6 +1921,7 @@ var VIDEO_MODELS = [
|
|
|
1877
1921
|
aspectRatios: [...KLING_RATIOS],
|
|
1878
1922
|
durations: { min: 3, max: 10 },
|
|
1879
1923
|
requires: ["sourceVideo"],
|
|
1924
|
+
sourceVideoSeconds: { min: 3, max: 10.05 },
|
|
1880
1925
|
supports: []
|
|
1881
1926
|
},
|
|
1882
1927
|
defaults: { durationSeconds: 5, aspectRatio: "16:9" },
|
|
@@ -2216,6 +2261,7 @@ var SupportedOptionSchema = import_zod2.z.enum([
|
|
|
2216
2261
|
"watermark",
|
|
2217
2262
|
"safetyChecker",
|
|
2218
2263
|
"taskType",
|
|
2264
|
+
"videoExtension",
|
|
2219
2265
|
"instrumental"
|
|
2220
2266
|
]);
|
|
2221
2267
|
var UsageUnitSchema = import_zod2.z.enum([
|
|
@@ -2236,13 +2282,20 @@ var ProviderOptionValueSchema = import_zod2.z.lazy(
|
|
|
2236
2282
|
])
|
|
2237
2283
|
);
|
|
2238
2284
|
var ProviderOptionsSchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.record(import_zod2.z.string(), ProviderOptionValueSchema));
|
|
2285
|
+
var VideoSecondsLimitsSchema = import_zod2.z.looseObject({
|
|
2286
|
+
min: import_zod2.z.number().optional(),
|
|
2287
|
+
max: import_zod2.z.number().optional(),
|
|
2288
|
+
total: import_zod2.z.number().optional(),
|
|
2289
|
+
editMin: import_zod2.z.number().optional()
|
|
2290
|
+
});
|
|
2239
2291
|
var ReferenceLimitsSchema = import_zod2.z.looseObject({
|
|
2240
2292
|
images: import_zod2.z.number().optional(),
|
|
2241
2293
|
imagesWithVideo: import_zod2.z.number().optional(),
|
|
2242
2294
|
videos: import_zod2.z.number().optional(),
|
|
2243
2295
|
audios: import_zod2.z.number().optional(),
|
|
2244
2296
|
total: import_zod2.z.number().optional(),
|
|
2245
|
-
audioOnly: import_zod2.z.boolean().optional()
|
|
2297
|
+
audioOnly: import_zod2.z.boolean().optional(),
|
|
2298
|
+
videoSeconds: VideoSecondsLimitsSchema.optional()
|
|
2246
2299
|
});
|
|
2247
2300
|
var ModelConstraintsSchema = import_zod2.z.looseObject({
|
|
2248
2301
|
aspectRatios: import_zod2.z.array(AspectRatioSchema).optional(),
|
|
@@ -2255,14 +2308,21 @@ var ModelConstraintsSchema = import_zod2.z.looseObject({
|
|
|
2255
2308
|
references: ReferenceLimitsSchema.optional(),
|
|
2256
2309
|
requires: import_zod2.z.array(RequiredInputSchema).optional(),
|
|
2257
2310
|
supports: import_zod2.z.array(SupportedOptionSchema).optional(),
|
|
2258
|
-
ratioIgnoredWith: import_zod2.z.array(import_zod2.z.enum(["firstFrame", "sourceVideo"])).optional()
|
|
2311
|
+
ratioIgnoredWith: import_zod2.z.array(import_zod2.z.enum(["firstFrame", "sourceVideo"])).optional(),
|
|
2312
|
+
sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: import_zod2.z.boolean().optional() }).optional(),
|
|
2313
|
+
extension: import_zod2.z.looseObject({ segmentSeconds: import_zod2.z.number(), maxTotalSeconds: import_zod2.z.number() }).optional()
|
|
2259
2314
|
});
|
|
2260
2315
|
var MediaRefSchema = import_zod2.z.union([
|
|
2261
|
-
import_zod2.z.looseObject({
|
|
2316
|
+
import_zod2.z.looseObject({
|
|
2317
|
+
url: import_zod2.z.string(),
|
|
2318
|
+
label: import_zod2.z.string().optional(),
|
|
2319
|
+
durationSeconds: import_zod2.z.number().optional()
|
|
2320
|
+
}),
|
|
2262
2321
|
import_zod2.z.looseObject({
|
|
2263
2322
|
bytes: import_zod2.z.instanceof(Uint8Array),
|
|
2264
2323
|
mime: import_zod2.z.string(),
|
|
2265
|
-
label: import_zod2.z.string().optional()
|
|
2324
|
+
label: import_zod2.z.string().optional(),
|
|
2325
|
+
durationSeconds: import_zod2.z.number().optional()
|
|
2266
2326
|
})
|
|
2267
2327
|
]);
|
|
2268
2328
|
var ImageSafetySettingSchema = import_zod2.z.looseObject({ category: import_zod2.z.string(), threshold: import_zod2.z.string() });
|
|
@@ -4517,12 +4577,34 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
4517
4577
|
const modelId = ctx.model.id;
|
|
4518
4578
|
const providerModelId = ctx.model.providerModelId;
|
|
4519
4579
|
const duration = req.durationSeconds ?? 10;
|
|
4520
|
-
const
|
|
4521
|
-
const
|
|
4522
|
-
const
|
|
4580
|
+
const extend = req.taskType === "extend";
|
|
4581
|
+
const previousId = extend ? req.previousInteractionId : void 0;
|
|
4582
|
+
const chained = previousId !== void 0;
|
|
4583
|
+
for (const field of ["referenceImages", "referenceVideos", "firstFrame"]) {
|
|
4584
|
+
const value = req[field];
|
|
4585
|
+
if (!chained || value === void 0 || Array.isArray(value) && value.length === 0)
|
|
4586
|
+
continue;
|
|
4587
|
+
ctx.warnings.push({
|
|
4588
|
+
code: "option_ignored",
|
|
4589
|
+
field,
|
|
4590
|
+
from: Array.isArray(value) ? value.length : "set",
|
|
4591
|
+
message: `${modelId} chained extension sends the prompt alone; ${field} ignored`
|
|
4592
|
+
});
|
|
4593
|
+
}
|
|
4594
|
+
const images = chained ? [] : req.referenceImages ?? [];
|
|
4595
|
+
const videos = chained ? [] : req.referenceVideos ?? [];
|
|
4596
|
+
const firstFrame = chained ? void 0 : req.firstFrame;
|
|
4597
|
+
if (extend && !chained && req.sourceVideo === void 0) {
|
|
4598
|
+
throw new ModelKitError({
|
|
4599
|
+
code: "missing_input",
|
|
4600
|
+
message: `${modelId} extend needs a source video or a previousInteractionId`,
|
|
4601
|
+
model: modelId
|
|
4602
|
+
});
|
|
4603
|
+
}
|
|
4604
|
+
const task = extend ? "extend" : req.sourceVideo ? "edit" : firstFrame ? "image_to_video" : images.length > 0 || videos.length > 0 ? "reference_to_video" : "text_to_video";
|
|
4523
4605
|
const isOmniV1 = providerModelId === "gemini-omni-flash-preview";
|
|
4524
4606
|
const responseFormat = { type: "video", delivery: "uri" };
|
|
4525
|
-
if (req.sourceVideo === void 0 && req.aspectRatio !== void 0 && req.aspectRatio !== "adaptive") {
|
|
4607
|
+
if (req.sourceVideo === void 0 && !extend && req.aspectRatio !== void 0 && req.aspectRatio !== "adaptive") {
|
|
4526
4608
|
responseFormat.aspect_ratio = toOmniAspect(req.aspectRatio);
|
|
4527
4609
|
}
|
|
4528
4610
|
if (!isOmniV1) {
|
|
@@ -4554,18 +4636,26 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
4554
4636
|
const cleanupUploads = async () => {
|
|
4555
4637
|
for (const fileName of uploadedNames) await deleteGoogleFile(fileName, apiKey, ctx.fetch);
|
|
4556
4638
|
};
|
|
4557
|
-
const callCreate = (input) => client2.interactions.create(
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4639
|
+
const callCreate = (input) => client2.interactions.create(
|
|
4640
|
+
previousId !== void 0 ? {
|
|
4641
|
+
model: providerModelId,
|
|
4642
|
+
input,
|
|
4643
|
+
response_format: responseFormat,
|
|
4644
|
+
store: true,
|
|
4645
|
+
previous_interaction_id: previousId
|
|
4646
|
+
} : {
|
|
4647
|
+
model: providerModelId,
|
|
4648
|
+
input,
|
|
4649
|
+
response_format: responseFormat,
|
|
4650
|
+
generation_config: { video_config: { task } },
|
|
4651
|
+
store: true
|
|
4652
|
+
}
|
|
4653
|
+
);
|
|
4564
4654
|
const createRetryOptions = mediaRetryOptions(ctx.call, ctx.signal);
|
|
4565
4655
|
let interaction;
|
|
4566
4656
|
try {
|
|
4567
4657
|
const parts = [];
|
|
4568
|
-
if (req.sourceVideo) {
|
|
4658
|
+
if (req.sourceVideo && !chained) {
|
|
4569
4659
|
const media = await resolveMedia(
|
|
4570
4660
|
req.sourceVideo,
|
|
4571
4661
|
ctx.fetch,
|
|
@@ -4588,11 +4678,11 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
4588
4678
|
mime_type: media.mime
|
|
4589
4679
|
});
|
|
4590
4680
|
}
|
|
4591
|
-
if (
|
|
4592
|
-
if (
|
|
4593
|
-
parts.push({ type: "text", text:
|
|
4681
|
+
if (firstFrame) {
|
|
4682
|
+
if (firstFrame.label !== void 0)
|
|
4683
|
+
parts.push({ type: "text", text: firstFrame.label });
|
|
4594
4684
|
const media = await resolveMedia(
|
|
4595
|
-
|
|
4685
|
+
firstFrame,
|
|
4596
4686
|
ctx.fetch,
|
|
4597
4687
|
ctx.signal,
|
|
4598
4688
|
"image/png",
|
|
@@ -4695,6 +4785,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
4695
4785
|
return void 0;
|
|
4696
4786
|
}, pollOptions);
|
|
4697
4787
|
const video = extractOmniVideo(done, modelId);
|
|
4788
|
+
const providerRef = { interactionId: done.id ?? jobId };
|
|
4698
4789
|
if (video.data) {
|
|
4699
4790
|
return {
|
|
4700
4791
|
video: {
|
|
@@ -4702,14 +4793,16 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
4702
4793
|
mime: video.mime_type ?? "video/mp4"
|
|
4703
4794
|
},
|
|
4704
4795
|
usage: usage2,
|
|
4705
|
-
raw: done
|
|
4796
|
+
raw: done,
|
|
4797
|
+
providerRef
|
|
4706
4798
|
};
|
|
4707
4799
|
}
|
|
4708
4800
|
if (video.uri)
|
|
4709
4801
|
return {
|
|
4710
4802
|
video: await downloadVideo(ctx, video.uri, apiKey, signal),
|
|
4711
4803
|
usage: usage2,
|
|
4712
|
-
raw: done
|
|
4804
|
+
raw: done,
|
|
4805
|
+
providerRef
|
|
4713
4806
|
};
|
|
4714
4807
|
throw classifyHttpError(
|
|
4715
4808
|
void 0,
|
|
@@ -6647,8 +6740,8 @@ function lyriaAudioInput(req, ctx) {
|
|
|
6647
6740
|
if (negative) input.negative_prompt = negative;
|
|
6648
6741
|
return input;
|
|
6649
6742
|
}
|
|
6650
|
-
function elevenLabsMusicDuration(
|
|
6651
|
-
return Math.min(300, Math.max(5,
|
|
6743
|
+
function elevenLabsMusicDuration(seconds2) {
|
|
6744
|
+
return Math.min(300, Math.max(5, seconds2 ?? 15));
|
|
6652
6745
|
}
|
|
6653
6746
|
function elevenLabsMusicInput(req, ctx) {
|
|
6654
6747
|
const prompt = req.prompt.trim();
|
|
@@ -6713,9 +6806,9 @@ async function generateReplicateAudio(req, ctx, deps) {
|
|
|
6713
6806
|
const { url, predictTime, raw } = await runPrediction(ctx, input, deps);
|
|
6714
6807
|
const usage2 = audioUsage(ctx, req);
|
|
6715
6808
|
if (ctx.model.usage.unit === "seconds") {
|
|
6716
|
-
const
|
|
6717
|
-
usage2.quantity =
|
|
6718
|
-
usage2.durationSeconds =
|
|
6809
|
+
const seconds2 = elevenLabsMusicDuration(req.durationSeconds);
|
|
6810
|
+
usage2.quantity = seconds2;
|
|
6811
|
+
usage2.durationSeconds = seconds2;
|
|
6719
6812
|
} else {
|
|
6720
6813
|
usage2.quantity = predictTime;
|
|
6721
6814
|
}
|
|
@@ -7355,6 +7448,49 @@ function trim(field, refs, limit, model, warnings) {
|
|
|
7355
7448
|
});
|
|
7356
7449
|
return refs.slice(0, limit);
|
|
7357
7450
|
}
|
|
7451
|
+
function knownLength(value) {
|
|
7452
|
+
return value !== void 0 && Number.isFinite(value) ? value : void 0;
|
|
7453
|
+
}
|
|
7454
|
+
function seconds(len, limit) {
|
|
7455
|
+
let digits = 1;
|
|
7456
|
+
while (digits < 3 && Number(len.toFixed(digits)) === limit) digits++;
|
|
7457
|
+
return len.toFixed(digits);
|
|
7458
|
+
}
|
|
7459
|
+
function effectiveMin(limits, taskType) {
|
|
7460
|
+
if (taskType !== "edit" || limits?.editMin === void 0) return limits?.min;
|
|
7461
|
+
return Math.max(limits.min ?? 0, limits.editMin);
|
|
7462
|
+
}
|
|
7463
|
+
function videoLengthViolation(model, input) {
|
|
7464
|
+
const limits = model.constraints.references?.videoSeconds;
|
|
7465
|
+
const refMin = effectiveMin(limits, input.taskType);
|
|
7466
|
+
const lengths = (input.referenceVideos ?? []).map(knownLength);
|
|
7467
|
+
if (limits?.max !== void 0) {
|
|
7468
|
+
const max = limits.max;
|
|
7469
|
+
const i = lengths.findIndex((len) => len !== void 0 && len > max);
|
|
7470
|
+
if (i >= 0)
|
|
7471
|
+
return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
|
|
7472
|
+
}
|
|
7473
|
+
if (refMin !== void 0) {
|
|
7474
|
+
const i = lengths.findIndex((len) => len !== void 0 && len < refMin);
|
|
7475
|
+
if (i >= 0)
|
|
7476
|
+
return `${model.label} takes reference videos of at least ${String(refMin)} s each; video ${i + 1} is ${seconds(lengths[i], refMin)} s.`;
|
|
7477
|
+
}
|
|
7478
|
+
const source = knownLength(input.sourceVideo);
|
|
7479
|
+
const sourceLimits = model.constraints.sourceVideoSeconds;
|
|
7480
|
+
if (limits?.total !== void 0) {
|
|
7481
|
+
const refSum = lengths.reduce((acc, len) => acc + (len ?? 0), 0);
|
|
7482
|
+
const sum = refSum + (sourceLimits?.inReferenceTotal ? source ?? 0 : 0);
|
|
7483
|
+
if (sum > limits.total)
|
|
7484
|
+
return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
|
|
7485
|
+
}
|
|
7486
|
+
if (source === void 0) return void 0;
|
|
7487
|
+
const sourceMin = effectiveMin(sourceLimits, input.taskType);
|
|
7488
|
+
if (sourceLimits?.max !== void 0 && source > sourceLimits.max)
|
|
7489
|
+
return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
|
|
7490
|
+
if (sourceMin !== void 0 && source < sourceMin)
|
|
7491
|
+
return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;
|
|
7492
|
+
return void 0;
|
|
7493
|
+
}
|
|
7358
7494
|
function resolveImageOptions(model, request, onUnsupported = "error") {
|
|
7359
7495
|
const warnings = [];
|
|
7360
7496
|
const c = model.constraints;
|
|
@@ -7540,9 +7676,25 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
7540
7676
|
model: model.id
|
|
7541
7677
|
});
|
|
7542
7678
|
}
|
|
7679
|
+
const lengthViolation = videoLengthViolation(model, {
|
|
7680
|
+
referenceVideos: videos.map((v) => v.durationSeconds),
|
|
7681
|
+
taskType: merged.taskType,
|
|
7682
|
+
...merged.sourceVideo?.durationSeconds !== void 0 && {
|
|
7683
|
+
sourceVideo: merged.sourceVideo.durationSeconds
|
|
7684
|
+
}
|
|
7685
|
+
});
|
|
7686
|
+
if (lengthViolation !== void 0) {
|
|
7687
|
+
throw new ModelKitError({
|
|
7688
|
+
code: "unsupported_option",
|
|
7689
|
+
message: lengthViolation,
|
|
7690
|
+
model: model.id,
|
|
7691
|
+
retryable: false
|
|
7692
|
+
});
|
|
7693
|
+
}
|
|
7543
7694
|
setOrDelete(merged, "referenceImages", images);
|
|
7544
7695
|
setOrDelete(merged, "referenceVideos", videos);
|
|
7545
7696
|
setOrDelete(merged, "referenceAudios", audios);
|
|
7697
|
+
const keepExtend = merged.taskType === "extend" && (model.constraints.supports ?? []).includes("videoExtension");
|
|
7546
7698
|
dropUnsupported(merged, model, warnings, [
|
|
7547
7699
|
"seed",
|
|
7548
7700
|
"negativePrompt",
|
|
@@ -7552,8 +7704,17 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
7552
7704
|
"lastFrame",
|
|
7553
7705
|
"watermark",
|
|
7554
7706
|
"safetyChecker",
|
|
7555
|
-
"taskType"
|
|
7707
|
+
...keepExtend ? [] : ["taskType"]
|
|
7556
7708
|
]);
|
|
7709
|
+
if (merged.previousInteractionId !== void 0 && !keepExtend) {
|
|
7710
|
+
warnings.push({
|
|
7711
|
+
code: "option_ignored",
|
|
7712
|
+
field: "previousInteractionId",
|
|
7713
|
+
from: merged.previousInteractionId,
|
|
7714
|
+
message: `${model.id} does not support previousInteractionId; ignored`
|
|
7715
|
+
});
|
|
7716
|
+
delete merged.previousInteractionId;
|
|
7717
|
+
}
|
|
7557
7718
|
return { request: merged, warnings };
|
|
7558
7719
|
}
|
|
7559
7720
|
function resolveAudioOptions(model, request, onUnsupported = "error") {
|
|
@@ -8090,7 +8251,7 @@ function createModelKit(config, adapters) {
|
|
|
8090
8251
|
promptExpansion: _promptExpansion,
|
|
8091
8252
|
mode: _mode
|
|
8092
8253
|
} = req;
|
|
8093
|
-
const
|
|
8254
|
+
const seconds2 = duration ?? durationSeconds;
|
|
8094
8255
|
const abortSignal = combineSignals(req.abortSignal, call.signal);
|
|
8095
8256
|
const options = { model, prompt };
|
|
8096
8257
|
if (call.maxRetries !== void 0) options.maxRetries = call.maxRetries;
|
|
@@ -8099,7 +8260,7 @@ function createModelKit(config, adapters) {
|
|
|
8099
8260
|
if (ratio) options.aspectRatio = ratio;
|
|
8100
8261
|
else if (aspectRatio !== void 0)
|
|
8101
8262
|
pushIgnored(warnings, "aspectRatio", aspectRatio, model.modelId);
|
|
8102
|
-
if (
|
|
8263
|
+
if (seconds2 !== void 0) options.duration = seconds2;
|
|
8103
8264
|
if (seed !== void 0) options.seed = seed;
|
|
8104
8265
|
if (generateAudio2 !== void 0) options.generateAudio = generateAudio2;
|
|
8105
8266
|
const frames = [
|
|
@@ -8146,8 +8307,8 @@ function createModelKit(config, adapters) {
|
|
|
8146
8307
|
provider: model.provider,
|
|
8147
8308
|
modality: "VIDEO",
|
|
8148
8309
|
unit: "seconds",
|
|
8149
|
-
quantity:
|
|
8150
|
-
...
|
|
8310
|
+
quantity: seconds2 ?? 0,
|
|
8311
|
+
...seconds2 !== void 0 && { durationSeconds: seconds2 }
|
|
8151
8312
|
};
|
|
8152
8313
|
settled = {
|
|
8153
8314
|
video: { bytes: result.video.uint8Array, mime: result.video.mediaType },
|
|
@@ -8498,6 +8659,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
|
|
|
8498
8659
|
textUsageEvent,
|
|
8499
8660
|
toGeneratedImage,
|
|
8500
8661
|
validateInputSpec,
|
|
8662
|
+
videoLengthViolation,
|
|
8501
8663
|
withRetry,
|
|
8502
8664
|
xaiVideoAdapter,
|
|
8503
8665
|
...require("ai")
|