@shop-os/modelkit 0.4.4 → 0.4.5
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 +5 -0
- package/dist/catalog.cjs +23 -6
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +23 -6
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/catalog.js
CHANGED
|
@@ -3260,6 +3260,20 @@ function resetLiveCatalog() {
|
|
|
3260
3260
|
|
|
3261
3261
|
// src/catalog/video-tools-spec.ts
|
|
3262
3262
|
import { z as z6 } from "zod";
|
|
3263
|
+
|
|
3264
|
+
// src/video-length.ts
|
|
3265
|
+
function tenths(seconds2) {
|
|
3266
|
+
return Math.round(seconds2 * 10) / 10;
|
|
3267
|
+
}
|
|
3268
|
+
function overMax(seconds2, max) {
|
|
3269
|
+
return seconds2 > max && tenths(seconds2) > max;
|
|
3270
|
+
}
|
|
3271
|
+
function overTotal(lengths, total) {
|
|
3272
|
+
const sum = (values) => values.reduce((acc, len) => acc + len, 0);
|
|
3273
|
+
return sum(lengths) > total && tenths(sum(lengths.map(tenths))) > total;
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
// src/catalog/video-tools-spec.ts
|
|
3263
3277
|
var RangeSchema2 = z6.object({ min: z6.number(), max: z6.number() });
|
|
3264
3278
|
var ToolSchema = z6.object({
|
|
3265
3279
|
kind: z6.enum(["upscale", "interpolate", "hdr"]),
|
|
@@ -3303,7 +3317,7 @@ function planVideoTool(row, req) {
|
|
|
3303
3317
|
return fail("The source video's width, height and duration are required");
|
|
3304
3318
|
}
|
|
3305
3319
|
const maxSeconds = row.constraints.sourceVideoSeconds?.max;
|
|
3306
|
-
if (maxSeconds !== void 0 && durationSeconds
|
|
3320
|
+
if (maxSeconds !== void 0 && overMax(durationSeconds, maxSeconds)) {
|
|
3307
3321
|
return fail(`${row.label} takes source videos up to ${maxSeconds} seconds.`);
|
|
3308
3322
|
}
|
|
3309
3323
|
const base = {
|
|
@@ -3500,7 +3514,7 @@ function videoLengthViolation(model, input) {
|
|
|
3500
3514
|
const lengths = (input.referenceVideos ?? []).map(knownLength);
|
|
3501
3515
|
if (limits?.max !== void 0) {
|
|
3502
3516
|
const max = limits.max;
|
|
3503
|
-
const i = lengths.findIndex((len) => len !== void 0 && len
|
|
3517
|
+
const i = lengths.findIndex((len) => len !== void 0 && overMax(len, max));
|
|
3504
3518
|
if (i >= 0)
|
|
3505
3519
|
return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
|
|
3506
3520
|
}
|
|
@@ -3512,14 +3526,17 @@ function videoLengthViolation(model, input) {
|
|
|
3512
3526
|
const source = knownLength(input.sourceVideo);
|
|
3513
3527
|
const sourceLimits = model.constraints.sourceVideoSeconds;
|
|
3514
3528
|
if (limits?.total !== void 0) {
|
|
3515
|
-
const
|
|
3516
|
-
|
|
3517
|
-
|
|
3529
|
+
const counted = [
|
|
3530
|
+
...lengths.filter((len) => len !== void 0),
|
|
3531
|
+
...sourceLimits?.inReferenceTotal && source !== void 0 ? [source] : []
|
|
3532
|
+
];
|
|
3533
|
+
const sum = counted.reduce((acc, len) => acc + len, 0);
|
|
3534
|
+
if (overTotal(counted, limits.total))
|
|
3518
3535
|
return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
|
|
3519
3536
|
}
|
|
3520
3537
|
if (source === void 0) return void 0;
|
|
3521
3538
|
const sourceMin = effectiveMin(sourceLimits, input.taskType);
|
|
3522
|
-
if (sourceLimits?.max !== void 0 && source
|
|
3539
|
+
if (sourceLimits?.max !== void 0 && overMax(source, sourceLimits.max))
|
|
3523
3540
|
return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
|
|
3524
3541
|
if (sourceMin !== void 0 && source < sourceMin)
|
|
3525
3542
|
return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;
|