@shop-os/modelkit 0.3.3 → 0.3.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 +19 -0
- package/dist/catalog.cjs +69 -8
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +10 -1
- package/dist/catalog.d.ts +10 -1
- package/dist/catalog.js +69 -8
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +80 -11
- 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 +80 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -152,6 +152,8 @@ interface VideoToolRequest {
|
|
|
152
152
|
source: VideoToolSource;
|
|
153
153
|
/** Upscale rows. */
|
|
154
154
|
upscaleFactor?: number;
|
|
155
|
+
/** Upscale rows whose `constraints.tool.prompt` is set; ignored by every other row. */
|
|
156
|
+
prompt?: string;
|
|
155
157
|
/** Interpolate rows. */
|
|
156
158
|
targetFps?: number;
|
|
157
159
|
/** HDR rows; the row's first `outputFormats` entry when unset. */
|
|
@@ -274,6 +276,8 @@ interface VideoToolConstraints {
|
|
|
274
276
|
};
|
|
275
277
|
/** Upscale: the output's long edge may not pass this, in pixels. */
|
|
276
278
|
maxOutputLongEdge?: number;
|
|
279
|
+
/** Upscale: the row takes an optional prompt that guides added detail. */
|
|
280
|
+
prompt?: boolean;
|
|
277
281
|
/** Interpolate: allowed target frame rate range. */
|
|
278
282
|
fps?: {
|
|
279
283
|
min: number;
|
|
@@ -821,6 +825,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
821
825
|
max: z.ZodNumber;
|
|
822
826
|
}, z.core.$loose>>;
|
|
823
827
|
maxOutputLongEdge: z.ZodOptional<z.ZodNumber>;
|
|
828
|
+
prompt: z.ZodOptional<z.ZodBoolean>;
|
|
824
829
|
fps: z.ZodOptional<z.ZodObject<{
|
|
825
830
|
min: z.ZodNumber;
|
|
826
831
|
max: z.ZodNumber;
|
|
@@ -1414,7 +1419,11 @@ declare function planVideoTool(row: CatalogModel, req: Omit<VideoToolRequest, "m
|
|
|
1414
1419
|
|
|
1415
1420
|
/**
|
|
1416
1421
|
* Topaz Labs video tools on fal. `providerOptions.fal.model` names the Topaz model the
|
|
1417
|
-
* endpoint runs; the adapter sends it as `model`.
|
|
1422
|
+
* endpoint runs; the adapter sends it as `model`. Precision and Starlight are also listed in
|
|
1423
|
+
* Space Builder's video upscale node.
|
|
1424
|
+
*
|
|
1425
|
+
* FLUX video upscale on fal: one endpoint, two rows, because fal prices its `creativity`
|
|
1426
|
+
* modes differently and pricing is keyed by model. `providerOptions.fal.input` fixes the mode.
|
|
1418
1427
|
*/
|
|
1419
1428
|
declare const VIDEO_TOOL_MODELS: CatalogModel[];
|
|
1420
1429
|
|
package/dist/index.d.ts
CHANGED
|
@@ -152,6 +152,8 @@ interface VideoToolRequest {
|
|
|
152
152
|
source: VideoToolSource;
|
|
153
153
|
/** Upscale rows. */
|
|
154
154
|
upscaleFactor?: number;
|
|
155
|
+
/** Upscale rows whose `constraints.tool.prompt` is set; ignored by every other row. */
|
|
156
|
+
prompt?: string;
|
|
155
157
|
/** Interpolate rows. */
|
|
156
158
|
targetFps?: number;
|
|
157
159
|
/** HDR rows; the row's first `outputFormats` entry when unset. */
|
|
@@ -274,6 +276,8 @@ interface VideoToolConstraints {
|
|
|
274
276
|
};
|
|
275
277
|
/** Upscale: the output's long edge may not pass this, in pixels. */
|
|
276
278
|
maxOutputLongEdge?: number;
|
|
279
|
+
/** Upscale: the row takes an optional prompt that guides added detail. */
|
|
280
|
+
prompt?: boolean;
|
|
277
281
|
/** Interpolate: allowed target frame rate range. */
|
|
278
282
|
fps?: {
|
|
279
283
|
min: number;
|
|
@@ -821,6 +825,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
821
825
|
max: z.ZodNumber;
|
|
822
826
|
}, z.core.$loose>>;
|
|
823
827
|
maxOutputLongEdge: z.ZodOptional<z.ZodNumber>;
|
|
828
|
+
prompt: z.ZodOptional<z.ZodBoolean>;
|
|
824
829
|
fps: z.ZodOptional<z.ZodObject<{
|
|
825
830
|
min: z.ZodNumber;
|
|
826
831
|
max: z.ZodNumber;
|
|
@@ -1414,7 +1419,11 @@ declare function planVideoTool(row: CatalogModel, req: Omit<VideoToolRequest, "m
|
|
|
1414
1419
|
|
|
1415
1420
|
/**
|
|
1416
1421
|
* Topaz Labs video tools on fal. `providerOptions.fal.model` names the Topaz model the
|
|
1417
|
-
* endpoint runs; the adapter sends it as `model`.
|
|
1422
|
+
* endpoint runs; the adapter sends it as `model`. Precision and Starlight are also listed in
|
|
1423
|
+
* Space Builder's video upscale node.
|
|
1424
|
+
*
|
|
1425
|
+
* FLUX video upscale on fal: one endpoint, two rows, because fal prices its `creativity`
|
|
1426
|
+
* modes differently and pricing is keyed by model. `providerOptions.fal.input` fixes the mode.
|
|
1418
1427
|
*/
|
|
1419
1428
|
declare const VIDEO_TOOL_MODELS: CatalogModel[];
|
|
1420
1429
|
|
package/dist/index.js
CHANGED
|
@@ -2013,8 +2013,16 @@ var VIDEO_MODELS = [
|
|
|
2013
2013
|
|
|
2014
2014
|
// src/catalog/video-tools.ts
|
|
2015
2015
|
var TOPAZ_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/topazlabs.png";
|
|
2016
|
+
var FLUX_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/flux.png";
|
|
2016
2017
|
var TOPAZ_SOURCE_SECONDS = { max: 300 };
|
|
2017
|
-
var
|
|
2018
|
+
var SECONDS_USAGE = { unit: "seconds" };
|
|
2019
|
+
var FLUX_SOURCE_SECONDS = { max: 20 };
|
|
2020
|
+
var FLUX_UPSCALE_TOOL = {
|
|
2021
|
+
kind: "upscale",
|
|
2022
|
+
upscaleFactor: { min: 1.5, max: 3 },
|
|
2023
|
+
maxOutputLongEdge: 3840,
|
|
2024
|
+
prompt: true
|
|
2025
|
+
};
|
|
2018
2026
|
var VIDEO_TOOL_MODELS = [
|
|
2019
2027
|
{
|
|
2020
2028
|
id: "topaz-precision",
|
|
@@ -2024,7 +2032,7 @@ var VIDEO_TOOL_MODELS = [
|
|
|
2024
2032
|
adapter: "fal",
|
|
2025
2033
|
providerModelId: "topaz/upscale/video/precision",
|
|
2026
2034
|
lifecycle: "active",
|
|
2027
|
-
exposure: ["cowork"],
|
|
2035
|
+
exposure: ["cowork", "space_builder"],
|
|
2028
2036
|
constraints: {
|
|
2029
2037
|
supports: [],
|
|
2030
2038
|
sourceVideoSeconds: TOPAZ_SOURCE_SECONDS,
|
|
@@ -2032,7 +2040,7 @@ var VIDEO_TOOL_MODELS = [
|
|
|
2032
2040
|
},
|
|
2033
2041
|
defaults: {},
|
|
2034
2042
|
providerOptions: { fal: { model: "Proteus" } },
|
|
2035
|
-
usage:
|
|
2043
|
+
usage: SECONDS_USAGE,
|
|
2036
2044
|
pricingKind: "video_per_second",
|
|
2037
2045
|
display: {
|
|
2038
2046
|
provider: "topaz",
|
|
@@ -2049,7 +2057,7 @@ var VIDEO_TOOL_MODELS = [
|
|
|
2049
2057
|
adapter: "fal",
|
|
2050
2058
|
providerModelId: "topaz/upscale/video/generative",
|
|
2051
2059
|
lifecycle: "active",
|
|
2052
|
-
exposure: ["cowork"],
|
|
2060
|
+
exposure: ["cowork", "space_builder"],
|
|
2053
2061
|
constraints: {
|
|
2054
2062
|
supports: [],
|
|
2055
2063
|
sourceVideoSeconds: TOPAZ_SOURCE_SECONDS,
|
|
@@ -2057,7 +2065,7 @@ var VIDEO_TOOL_MODELS = [
|
|
|
2057
2065
|
},
|
|
2058
2066
|
defaults: {},
|
|
2059
2067
|
providerOptions: { fal: { model: "Starlight Precise 2.6" } },
|
|
2060
|
-
usage:
|
|
2068
|
+
usage: SECONDS_USAGE,
|
|
2061
2069
|
pricingKind: "video_per_second",
|
|
2062
2070
|
display: {
|
|
2063
2071
|
provider: "topaz",
|
|
@@ -2082,7 +2090,7 @@ var VIDEO_TOOL_MODELS = [
|
|
|
2082
2090
|
},
|
|
2083
2091
|
defaults: {},
|
|
2084
2092
|
providerOptions: { fal: { model: "Apollo" } },
|
|
2085
|
-
usage:
|
|
2093
|
+
usage: SECONDS_USAGE,
|
|
2086
2094
|
pricingKind: "video_per_second",
|
|
2087
2095
|
display: {
|
|
2088
2096
|
provider: "topaz",
|
|
@@ -2105,13 +2113,63 @@ var VIDEO_TOOL_MODELS = [
|
|
|
2105
2113
|
tool: { kind: "hdr", outputFormats: ["h265", "prores"] }
|
|
2106
2114
|
},
|
|
2107
2115
|
defaults: {},
|
|
2108
|
-
usage:
|
|
2116
|
+
usage: SECONDS_USAGE,
|
|
2109
2117
|
pricingKind: "video_per_second",
|
|
2110
2118
|
display: {
|
|
2111
2119
|
provider: "topaz",
|
|
2112
2120
|
logo: TOPAZ_LOGO,
|
|
2113
2121
|
description: "Topaz Hyperion 2.5 SDR to HDR: a 10-bit HDR master in H.265 (HDR10) or ProRes 422 HQ, at the source's size and frame rate."
|
|
2114
2122
|
}
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
id: "flux-video-upscale-precise",
|
|
2126
|
+
aliases: [],
|
|
2127
|
+
label: "FLUX Upscale Precise",
|
|
2128
|
+
type: "video-tool",
|
|
2129
|
+
adapter: "fal",
|
|
2130
|
+
providerModelId: "blackforestlabs/flux-video-upscale",
|
|
2131
|
+
lifecycle: "active",
|
|
2132
|
+
exposure: ["space_builder"],
|
|
2133
|
+
constraints: {
|
|
2134
|
+
supports: [],
|
|
2135
|
+
sourceVideoSeconds: FLUX_SOURCE_SECONDS,
|
|
2136
|
+
tool: FLUX_UPSCALE_TOOL
|
|
2137
|
+
},
|
|
2138
|
+
defaults: {},
|
|
2139
|
+
providerOptions: { fal: { input: { creativity: 0 } } },
|
|
2140
|
+
usage: SECONDS_USAGE,
|
|
2141
|
+
pricingKind: "video_per_second",
|
|
2142
|
+
display: {
|
|
2143
|
+
provider: "black-forest-labs",
|
|
2144
|
+
logo: FLUX_LOGO,
|
|
2145
|
+
description: "FLUX 3 super-resolution, source-faithful: 1.5x to 3x, up to 4K, for clips up to 20 seconds.",
|
|
2146
|
+
sortOrder: 30
|
|
2147
|
+
}
|
|
2148
|
+
},
|
|
2149
|
+
{
|
|
2150
|
+
id: "flux-video-upscale-creative",
|
|
2151
|
+
aliases: [],
|
|
2152
|
+
label: "FLUX Upscale Creative",
|
|
2153
|
+
type: "video-tool",
|
|
2154
|
+
adapter: "fal",
|
|
2155
|
+
providerModelId: "blackforestlabs/flux-video-upscale",
|
|
2156
|
+
lifecycle: "active",
|
|
2157
|
+
exposure: ["space_builder"],
|
|
2158
|
+
constraints: {
|
|
2159
|
+
supports: [],
|
|
2160
|
+
sourceVideoSeconds: FLUX_SOURCE_SECONDS,
|
|
2161
|
+
tool: FLUX_UPSCALE_TOOL
|
|
2162
|
+
},
|
|
2163
|
+
defaults: {},
|
|
2164
|
+
providerOptions: { fal: { input: { creativity: 1 } } },
|
|
2165
|
+
usage: SECONDS_USAGE,
|
|
2166
|
+
pricingKind: "video_per_second",
|
|
2167
|
+
display: {
|
|
2168
|
+
provider: "black-forest-labs",
|
|
2169
|
+
logo: FLUX_LOGO,
|
|
2170
|
+
description: "FLUX 3 super-resolution that adds fine detail, optionally guided by a prompt: 1.5x to 3x, up to 4K, for clips up to 20 seconds. Costs more than Precise.",
|
|
2171
|
+
sortOrder: 40
|
|
2172
|
+
}
|
|
2115
2173
|
}
|
|
2116
2174
|
];
|
|
2117
2175
|
|
|
@@ -2612,6 +2670,7 @@ var VideoToolConstraintsSchema = z3.looseObject({
|
|
|
2612
2670
|
kind: z3.enum(["upscale", "interpolate", "hdr"]),
|
|
2613
2671
|
upscaleFactor: RangeSchema.optional(),
|
|
2614
2672
|
maxOutputLongEdge: z3.number().positive().optional(),
|
|
2673
|
+
prompt: z3.boolean().optional(),
|
|
2615
2674
|
fps: RangeSchema.optional(),
|
|
2616
2675
|
outputFormats: z3.array(z3.enum(["h265", "prores"])).min(1).optional()
|
|
2617
2676
|
});
|
|
@@ -3907,6 +3966,7 @@ var ToolSchema = z10.object({
|
|
|
3907
3966
|
kind: z10.enum(["upscale", "interpolate", "hdr"]),
|
|
3908
3967
|
upscaleFactor: RangeSchema2.optional(),
|
|
3909
3968
|
maxOutputLongEdge: z10.number().positive().optional(),
|
|
3969
|
+
prompt: z10.boolean().optional(),
|
|
3910
3970
|
fps: RangeSchema2.optional(),
|
|
3911
3971
|
outputFormats: z10.array(z10.enum(["h265", "prores"])).min(1).optional()
|
|
3912
3972
|
});
|
|
@@ -3914,11 +3974,12 @@ function videoToolConstraints(row) {
|
|
|
3914
3974
|
if (row.type !== "video-tool") return void 0;
|
|
3915
3975
|
const parsed = ToolSchema.safeParse(row.constraints.tool);
|
|
3916
3976
|
if (!parsed.success) return void 0;
|
|
3917
|
-
const { kind, upscaleFactor, maxOutputLongEdge, fps, outputFormats } = parsed.data;
|
|
3977
|
+
const { kind, upscaleFactor, maxOutputLongEdge, prompt, fps, outputFormats } = parsed.data;
|
|
3918
3978
|
return {
|
|
3919
3979
|
kind,
|
|
3920
3980
|
...upscaleFactor !== void 0 && { upscaleFactor },
|
|
3921
3981
|
...maxOutputLongEdge !== void 0 && { maxOutputLongEdge },
|
|
3982
|
+
...prompt !== void 0 && { prompt },
|
|
3922
3983
|
...fps !== void 0 && { fps },
|
|
3923
3984
|
...outputFormats !== void 0 && { outputFormats }
|
|
3924
3985
|
};
|
|
@@ -4074,14 +4135,21 @@ async function readJson(ctx, res) {
|
|
|
4074
4135
|
function providerModelName(ctx) {
|
|
4075
4136
|
return z11.string().safeParse(ctx.model.providerOptions?.["fal"]?.["model"]).data;
|
|
4076
4137
|
}
|
|
4138
|
+
function staticInput(ctx) {
|
|
4139
|
+
return JsonObjectSchema.safeParse(ctx.model.providerOptions?.["fal"]?.["input"]).data ?? {};
|
|
4140
|
+
}
|
|
4077
4141
|
function toolInput(ctx, req, output) {
|
|
4078
4142
|
const tool = videoToolConstraints(ctx.model);
|
|
4079
4143
|
const model = providerModelName(ctx);
|
|
4080
|
-
const input = { video_url: req.source.url };
|
|
4144
|
+
const input = { ...staticInput(ctx), video_url: req.source.url };
|
|
4081
4145
|
if (tool?.kind === "upscale") {
|
|
4082
|
-
if (model !== void 0) input["model"] = model;
|
|
4083
4146
|
input["upscale_factor"] = req.upscaleFactor ?? 1;
|
|
4084
|
-
|
|
4147
|
+
if (model !== void 0) {
|
|
4148
|
+
input["model"] = model;
|
|
4149
|
+
input["H264_output"] = true;
|
|
4150
|
+
}
|
|
4151
|
+
const prompt = req.prompt?.trim();
|
|
4152
|
+
if (tool.prompt === true && prompt) input["prompt"] = prompt;
|
|
4085
4153
|
} else if (tool?.kind === "interpolate") {
|
|
4086
4154
|
if (model !== void 0) input["model"] = model;
|
|
4087
4155
|
input["target_fps"] = req.targetFps ?? 60;
|
|
@@ -7814,6 +7882,7 @@ function adapterServesType(adapter, type) {
|
|
|
7814
7882
|
}
|
|
7815
7883
|
if (type === "video") return adapter.generateVideo !== void 0;
|
|
7816
7884
|
if (type === "audio") return adapter.generateAudio !== void 0;
|
|
7885
|
+
if (type === "video-tool") return adapter.submitVideoTool !== void 0;
|
|
7817
7886
|
return adapter.languageModel !== void 0;
|
|
7818
7887
|
}
|
|
7819
7888
|
function dataOnlyCapable(row) {
|