@shop-os/modelkit 0.7.0 → 0.7.2
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 +16 -0
- package/dist/catalog.cjs +59 -2
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +36 -27
- package/dist/catalog.d.ts +36 -27
- package/dist/catalog.js +59 -2
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +63 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +61 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -89,6 +89,7 @@ __export(index_exports, {
|
|
|
89
89
|
liveCatalog: () => liveCatalog,
|
|
90
90
|
liveState: () => liveState,
|
|
91
91
|
lumaAdapter: () => lumaAdapter,
|
|
92
|
+
lumaReframeTooTall: () => lumaReframeTooTall,
|
|
92
93
|
mergeTextProviderOptions: () => mergeTextProviderOptions,
|
|
93
94
|
missingTierKeys: () => missingTierKeys,
|
|
94
95
|
model3dCall: () => model3dCall,
|
|
@@ -126,6 +127,7 @@ __export(index_exports, {
|
|
|
126
127
|
sortCatalogRows: () => sortCatalogRows,
|
|
127
128
|
streamObject: () => streamObject,
|
|
128
129
|
streamText: () => streamText,
|
|
130
|
+
takesTargetAspectRatio: () => takesTargetAspectRatio,
|
|
129
131
|
textUsageEvent: () => textUsageEvent,
|
|
130
132
|
toGeneratedImage: () => toGeneratedImage,
|
|
131
133
|
validateInputSpec: () => validateInputSpec,
|
|
@@ -6273,14 +6275,17 @@ var VIDEO_TOOL_MODELS = [
|
|
|
6273
6275
|
{
|
|
6274
6276
|
// https://fal.ai/models/fal-ai/flashvsr/upscale/video/api: upscale_factor 1-4, X264 MP4
|
|
6275
6277
|
// by default; fal bills $0.0005 per output megapixel-frame (width x height x frames).
|
|
6278
|
+
// Retired (ENG-3314): the price rows tier by short edge, which under-prices square, wide
|
|
6279
|
+
// and above-4k outputs.
|
|
6276
6280
|
id: "flashvsr",
|
|
6277
6281
|
aliases: ["flashvsr-upscale"],
|
|
6278
6282
|
label: "FlashVSR",
|
|
6279
6283
|
type: "video-tool",
|
|
6280
6284
|
adapter: "fal",
|
|
6281
6285
|
providerModelId: "fal-ai/flashvsr/upscale/video",
|
|
6282
|
-
lifecycle: "
|
|
6283
|
-
|
|
6286
|
+
lifecycle: "retired",
|
|
6287
|
+
replacedBy: "flux-video-upscale-precise",
|
|
6288
|
+
exposure: [],
|
|
6284
6289
|
constraints: {
|
|
6285
6290
|
supports: [],
|
|
6286
6291
|
tool: { kind: "upscale", upscaleFactor: { min: 1, max: 4 } }
|
|
@@ -6483,6 +6488,57 @@ function applyXaiVideoRules(model, req, onUnsupported, warnings) {
|
|
|
6483
6488
|
});
|
|
6484
6489
|
req.resolution = XAI_REFERENCE_MAX_RESOLUTION;
|
|
6485
6490
|
}
|
|
6491
|
+
function takesTargetAspectRatio(model) {
|
|
6492
|
+
const ratios = model.constraints.aspectRatios ?? [];
|
|
6493
|
+
return (model.constraints.requires ?? []).includes("sourceVideo") && ratios.length > 0 && !ratios.includes("adaptive");
|
|
6494
|
+
}
|
|
6495
|
+
var LUMA_REFRAME_VERTICAL_MAX_RESOLUTION = "720p";
|
|
6496
|
+
function lumaReframeTooTall(req) {
|
|
6497
|
+
const vertical = req.aspectRatio === "9:16" || req.aspectRatio === "3:4";
|
|
6498
|
+
return vertical && req.resolution === "1080p";
|
|
6499
|
+
}
|
|
6500
|
+
function applyLumaVideoRules(model, req, onUnsupported, warnings) {
|
|
6501
|
+
if (model.adapter !== "luma" || !takesTargetAspectRatio(model)) return;
|
|
6502
|
+
if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") {
|
|
6503
|
+
const listed2 = model.constraints.aspectRatios ?? [];
|
|
6504
|
+
const fallback = model.defaults.aspectRatio !== void 0 && model.defaults.aspectRatio !== "adaptive" ? model.defaults.aspectRatio : listed2[0];
|
|
6505
|
+
const message2 = `${model.id} needs a target aspect ratio: ${listed2.join(", ")}`;
|
|
6506
|
+
if (onUnsupported === "error" || fallback === void 0) {
|
|
6507
|
+
throw new ModelKitError({
|
|
6508
|
+
code: "unsupported_option",
|
|
6509
|
+
message: message2,
|
|
6510
|
+
model: model.id,
|
|
6511
|
+
retryable: false
|
|
6512
|
+
});
|
|
6513
|
+
}
|
|
6514
|
+
warnings.push({
|
|
6515
|
+
code: "ratio_coerced",
|
|
6516
|
+
field: "aspectRatio",
|
|
6517
|
+
from: req.aspectRatio ?? "adaptive",
|
|
6518
|
+
to: fallback,
|
|
6519
|
+
message: message2
|
|
6520
|
+
});
|
|
6521
|
+
req.aspectRatio = fallback;
|
|
6522
|
+
}
|
|
6523
|
+
if (!lumaReframeTooTall(req)) return;
|
|
6524
|
+
const message = `${model.id} renders 9:16 and 3:4 reframes at up to ${LUMA_REFRAME_VERTICAL_MAX_RESOLUTION}`;
|
|
6525
|
+
if (onUnsupported === "error") {
|
|
6526
|
+
throw new ModelKitError({
|
|
6527
|
+
code: "unsupported_option",
|
|
6528
|
+
message,
|
|
6529
|
+
model: model.id,
|
|
6530
|
+
retryable: false
|
|
6531
|
+
});
|
|
6532
|
+
}
|
|
6533
|
+
warnings.push({
|
|
6534
|
+
code: "resolution_coerced",
|
|
6535
|
+
field: "resolution",
|
|
6536
|
+
from: req.resolution,
|
|
6537
|
+
to: LUMA_REFRAME_VERTICAL_MAX_RESOLUTION,
|
|
6538
|
+
message
|
|
6539
|
+
});
|
|
6540
|
+
req.resolution = LUMA_REFRAME_VERTICAL_MAX_RESOLUTION;
|
|
6541
|
+
}
|
|
6486
6542
|
var MINIMAX_H3_INSERT = "minimax/h3-max/insert-video";
|
|
6487
6543
|
var INSERT_MIN = 1.625;
|
|
6488
6544
|
var INSERT_MAX = 60;
|
|
@@ -13911,16 +13967,12 @@ function lumaVideoMode(ctx) {
|
|
|
13911
13967
|
}
|
|
13912
13968
|
return mode;
|
|
13913
13969
|
}
|
|
13914
|
-
function reframeTooTall(req) {
|
|
13915
|
-
const vertical = req.aspectRatio === "9:16" || req.aspectRatio === "3:4";
|
|
13916
|
-
return vertical && req.resolution === "1080p";
|
|
13917
|
-
}
|
|
13918
13970
|
function sentResolution(req, mode) {
|
|
13919
|
-
return mode === "reframe" &&
|
|
13971
|
+
return mode === "reframe" && lumaReframeTooTall(req) ? "720p" : req.resolution;
|
|
13920
13972
|
}
|
|
13921
13973
|
function lumaReframeResolution(req, ctx) {
|
|
13922
13974
|
const requested = req.resolution;
|
|
13923
|
-
if (requested === void 0 || !
|
|
13975
|
+
if (requested === void 0 || !lumaReframeTooTall(req)) return requested;
|
|
13924
13976
|
const message = `${ctx.model.id} renders 9:16 and 3:4 reframes at up to 720p`;
|
|
13925
13977
|
if ((ctx.call.onUnsupported ?? "error") === "error") {
|
|
13926
13978
|
throw new ModelKitError({
|
|
@@ -16650,6 +16702,7 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
16650
16702
|
delete merged.previousInteractionId;
|
|
16651
16703
|
}
|
|
16652
16704
|
applyXaiVideoRules(model, merged, onUnsupported, warnings);
|
|
16705
|
+
applyLumaVideoRules(model, merged, onUnsupported, warnings);
|
|
16653
16706
|
checkVideoRequired(model, merged);
|
|
16654
16707
|
applyFalVideoRules(model, merged, request.aspectRatio, warnings);
|
|
16655
16708
|
return { request: merged, warnings };
|
|
@@ -18248,6 +18301,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
|
|
|
18248
18301
|
liveCatalog,
|
|
18249
18302
|
liveState,
|
|
18250
18303
|
lumaAdapter,
|
|
18304
|
+
lumaReframeTooTall,
|
|
18251
18305
|
mergeTextProviderOptions,
|
|
18252
18306
|
missingTierKeys,
|
|
18253
18307
|
model3dCall,
|
|
@@ -18285,6 +18339,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
|
|
|
18285
18339
|
sortCatalogRows,
|
|
18286
18340
|
streamObject,
|
|
18287
18341
|
streamText,
|
|
18342
|
+
takesTargetAspectRatio,
|
|
18288
18343
|
textUsageEvent,
|
|
18289
18344
|
toGeneratedImage,
|
|
18290
18345
|
validateInputSpec,
|