@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/index.js
CHANGED
|
@@ -4132,6 +4132,20 @@ import { z as z11 } from "zod";
|
|
|
4132
4132
|
|
|
4133
4133
|
// src/catalog/video-tools-spec.ts
|
|
4134
4134
|
import { z as z10 } from "zod";
|
|
4135
|
+
|
|
4136
|
+
// src/video-length.ts
|
|
4137
|
+
function tenths(seconds2) {
|
|
4138
|
+
return Math.round(seconds2 * 10) / 10;
|
|
4139
|
+
}
|
|
4140
|
+
function overMax(seconds2, max) {
|
|
4141
|
+
return seconds2 > max && tenths(seconds2) > max;
|
|
4142
|
+
}
|
|
4143
|
+
function overTotal(lengths, total) {
|
|
4144
|
+
const sum = (values) => values.reduce((acc, len) => acc + len, 0);
|
|
4145
|
+
return sum(lengths) > total && tenths(sum(lengths.map(tenths))) > total;
|
|
4146
|
+
}
|
|
4147
|
+
|
|
4148
|
+
// src/catalog/video-tools-spec.ts
|
|
4135
4149
|
var RangeSchema2 = z10.object({ min: z10.number(), max: z10.number() });
|
|
4136
4150
|
var ToolSchema = z10.object({
|
|
4137
4151
|
kind: z10.enum(["upscale", "interpolate", "hdr"]),
|
|
@@ -4175,7 +4189,7 @@ function planVideoTool(row, req) {
|
|
|
4175
4189
|
return fail("The source video's width, height and duration are required");
|
|
4176
4190
|
}
|
|
4177
4191
|
const maxSeconds = row.constraints.sourceVideoSeconds?.max;
|
|
4178
|
-
if (maxSeconds !== void 0 && durationSeconds
|
|
4192
|
+
if (maxSeconds !== void 0 && overMax(durationSeconds, maxSeconds)) {
|
|
4179
4193
|
return fail(`${row.label} takes source videos up to ${maxSeconds} seconds.`);
|
|
4180
4194
|
}
|
|
4181
4195
|
const base = {
|
|
@@ -8579,7 +8593,7 @@ function videoLengthViolation(model, input) {
|
|
|
8579
8593
|
const lengths = (input.referenceVideos ?? []).map(knownLength);
|
|
8580
8594
|
if (limits?.max !== void 0) {
|
|
8581
8595
|
const max = limits.max;
|
|
8582
|
-
const i = lengths.findIndex((len) => len !== void 0 && len
|
|
8596
|
+
const i = lengths.findIndex((len) => len !== void 0 && overMax(len, max));
|
|
8583
8597
|
if (i >= 0)
|
|
8584
8598
|
return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
|
|
8585
8599
|
}
|
|
@@ -8591,14 +8605,17 @@ function videoLengthViolation(model, input) {
|
|
|
8591
8605
|
const source = knownLength(input.sourceVideo);
|
|
8592
8606
|
const sourceLimits = model.constraints.sourceVideoSeconds;
|
|
8593
8607
|
if (limits?.total !== void 0) {
|
|
8594
|
-
const
|
|
8595
|
-
|
|
8596
|
-
|
|
8608
|
+
const counted = [
|
|
8609
|
+
...lengths.filter((len) => len !== void 0),
|
|
8610
|
+
...sourceLimits?.inReferenceTotal && source !== void 0 ? [source] : []
|
|
8611
|
+
];
|
|
8612
|
+
const sum = counted.reduce((acc, len) => acc + len, 0);
|
|
8613
|
+
if (overTotal(counted, limits.total))
|
|
8597
8614
|
return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
|
|
8598
8615
|
}
|
|
8599
8616
|
if (source === void 0) return void 0;
|
|
8600
8617
|
const sourceMin = effectiveMin(sourceLimits, input.taskType);
|
|
8601
|
-
if (sourceLimits?.max !== void 0 && source
|
|
8618
|
+
if (sourceLimits?.max !== void 0 && overMax(source, sourceLimits.max))
|
|
8602
8619
|
return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
|
|
8603
8620
|
if (sourceMin !== void 0 && source < sourceMin)
|
|
8604
8621
|
return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;
|