@shop-os/modelkit 0.17.1 → 0.18.1
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 +24 -0
- package/dist/catalog.cjs +241 -15
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +78 -3
- package/dist/catalog.d.ts +78 -3
- package/dist/catalog.js +241 -15
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +328 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -3
- package/dist/index.d.ts +86 -3
- package/dist/index.js +326 -64
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,30 @@ header in the release PR.
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.18.1] - Unreleased
|
|
13
|
+
|
|
14
|
+
Gemini Omni 1.2 Flash (ENG-3761).
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- `gemini-omni-1.2-flash` (`google-genai`, aliases `gemini-omni-1.2-video`, `-reference`, `-edit`): the 1.1 Interactions API with 3-15 s output (presets 3, 5, 8, 10, 15) at 360p, 720p, 1080p and 4K, a source video up to 15 s, 6 reference images and 1 reference video, extensions to 30 s in all. Live-checked 2026-11-06: a 3 s and a 15 s 360p clip (15.04 s out). No `sortOrder` or `recommended`: those stay in the database.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- The Omni adapter refuses a start-and-end-frame clip or an extension segment over 10 s with `unsupported_option` before any provider call (Google caps both at 10 s on 1.2). 1.0 and 1.1 rows top out at 10 s, so nothing changes for them.
|
|
21
|
+
|
|
22
|
+
## [0.18.0] - Unreleased
|
|
23
|
+
|
|
24
|
+
GPT Image 2.6 output options: format, background and animated GIF.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- `ImageRequest.background` (`auto` | `opaque` | `transparent`), offered where `constraints.backgrounds` lists the value. The `openai-image` adapter sends it as `background`.
|
|
28
|
+
- `OutputFormat` gains `gif` and `svg`. An image row offers them only through the new `constraints.imageFormats` list; without one an image row takes png, jpeg and webp as before, and the resolver refuses (`error`) or drops (`coerce`) anything else. `imageFormats` is separate from `outputFormats`, which stays the audio-output list.
|
|
29
|
+
- Animated GIF: `ImageRequest.animation` (`frameCount`, `frameDurationMs`) with the frame size as `exactSize`, checked against `constraints.animation` (frame sizes with a frame range each, a duration range, defaults). The resolver fills the defaults, refuses or snaps out-of-range values, drops `aspectRatio`, and sets `size` to the tier the GIF bills at by its frame size (`animationTier`: frames up to 288x512 bill at 1K, larger ones at 2K; OpenAI's output tokens follow the frame size, not the frame count). The adapter sends `output_format: gif`, `size`, `frame_count` and `frame_duration_ms` and labels the result `image/gif`.
|
|
30
|
+
- SVG: `constraints.svgModel` names the text model OpenAI uses to write the SVG from the image (`svg: { model }`). SVG is refused with references (the edit endpoint has no SVG) and above one image per call; the source image follows the requested size. The adapter sends no `n`, labels the result `image/svg+xml` and cleans it (`sanitizeSvg`): scripts, `foreignObject` and embeds, `on*` handlers, `javascript:` and external links and CSS `@import` are removed, and an SVG that still looks active is refused (`provider_rejected`), since a prompt can steer the markup.
|
|
31
|
+
- `gpt-image-2.6-sunburst` and `gpt-image-2.6-flare` offer `png`, `gif` and `svg`, all three backgrounds, and GIF frames at 288x288, 384x384, 512x288, 288x512 and 512x512 (2-16 frames) and 768x768 (2-12), 20-2000 ms per frame, default 9 frames at 200 ms. OpenAI tiles the frames into one sheet that must stay within 3840 px a side and 8.3M px, so 1024x1024 fits no frame count; the API takes 16 frames at most today. `svgModel` is `gpt-6.1-sol`: OpenAI bills its tokens on top of the image (measured $0.012 to $0.163 per SVG), which pro-backend covers with a flat `gpt-image-svg` charge. All live-checked 2026-11-05.
|
|
32
|
+
- Exports `animationTier(model, frameSize)` and `imageOutputFormats`.
|
|
33
|
+
|
|
34
|
+
Kits before 0.18.0 ignore `imageFormats`, `backgrounds`, `animation` and `svgModel` (they read rows loosely), so a live row carrying them stays valid for older consumers.
|
|
35
|
+
|
|
12
36
|
## [0.17.1] - Unreleased
|
|
13
37
|
|
|
14
38
|
GPT Image 2.6 rows in the snapshot (ENG-3735).
|
package/dist/catalog.cjs
CHANGED
|
@@ -525,6 +525,25 @@ var NANO_BANANA_2_1_RATIOS = [
|
|
|
525
525
|
"adaptive"
|
|
526
526
|
];
|
|
527
527
|
var GEMINI_PROMPT_MAX_CHARS = 5e4;
|
|
528
|
+
var GPT_IMAGE_2_6_ANIMATION = {
|
|
529
|
+
frameSizes: [
|
|
530
|
+
{ size: "288x288", minFrames: 2, maxFrames: 16 },
|
|
531
|
+
{ size: "384x384", minFrames: 2, maxFrames: 16 },
|
|
532
|
+
{ size: "512x288", minFrames: 2, maxFrames: 16 },
|
|
533
|
+
{ size: "288x512", minFrames: 2, maxFrames: 16 },
|
|
534
|
+
{ size: "512x512", minFrames: 2, maxFrames: 16 },
|
|
535
|
+
{ size: "768x768", minFrames: 2, maxFrames: 12 }
|
|
536
|
+
],
|
|
537
|
+
frameDurationMs: { min: 20, max: 2e3 },
|
|
538
|
+
defaultFrameCount: 9,
|
|
539
|
+
defaultFrameDurationMs: 200
|
|
540
|
+
};
|
|
541
|
+
var GPT_IMAGE_2_6_OUTPUT = {
|
|
542
|
+
imageFormats: ["png", "gif", "svg"],
|
|
543
|
+
backgrounds: ["auto", "opaque", "transparent"],
|
|
544
|
+
animation: GPT_IMAGE_2_6_ANIMATION,
|
|
545
|
+
svgModel: "gpt-6.1-sol"
|
|
546
|
+
};
|
|
528
547
|
var GPT_IMAGE_PROMPT = { referenceSyntax: "numbered", maxChars: 32e3 };
|
|
529
548
|
function geminiImage(id, label, aliases, sizes, display, exposure, references, promptMaxChars, aspectRatios = GEMINI_RATIOS) {
|
|
530
549
|
const prompt = { referenceSyntax: "caption" };
|
|
@@ -693,7 +712,8 @@ var IMAGE_MODELS = [
|
|
|
693
712
|
qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
|
|
694
713
|
references: { images: 16 },
|
|
695
714
|
supports: ["quality", "count", "outputFormat"],
|
|
696
|
-
prompt: GPT_IMAGE_PROMPT
|
|
715
|
+
prompt: GPT_IMAGE_PROMPT,
|
|
716
|
+
...GPT_IMAGE_2_6_OUTPUT
|
|
697
717
|
},
|
|
698
718
|
defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
|
|
699
719
|
usage: { ...IMAGE_USAGE3 },
|
|
@@ -728,7 +748,8 @@ var IMAGE_MODELS = [
|
|
|
728
748
|
qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
|
|
729
749
|
references: { images: 16 },
|
|
730
750
|
supports: ["quality", "count", "outputFormat"],
|
|
731
|
-
prompt: GPT_IMAGE_PROMPT
|
|
751
|
+
prompt: GPT_IMAGE_PROMPT,
|
|
752
|
+
...GPT_IMAGE_2_6_OUTPUT
|
|
732
753
|
},
|
|
733
754
|
defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
|
|
734
755
|
usage: { ...IMAGE_USAGE3 },
|
|
@@ -6101,6 +6122,44 @@ var VIDEO_MODELS = [
|
|
|
6101
6122
|
lastFrameRequiresFirstFrame: true
|
|
6102
6123
|
}
|
|
6103
6124
|
},
|
|
6125
|
+
{
|
|
6126
|
+
// https://aistudio.google.com/docs/omni (2026-11-05): the 1.1 Interactions API with
|
|
6127
|
+
// 3-15 s output; first-to-last-frame and each extension stay at 3-10 s (the adapter
|
|
6128
|
+
// refuses more), extended clips stop at 30 s, and 11-15 s clips take one reference video.
|
|
6129
|
+
id: "gemini-omni-1.2-flash",
|
|
6130
|
+
aliases: ["gemini-omni-1.2-video", "gemini-omni-1.2-reference", "gemini-omni-1.2-edit"],
|
|
6131
|
+
label: "Gemini Omni 1.2 Flash",
|
|
6132
|
+
type: "video",
|
|
6133
|
+
adapter: "google-genai",
|
|
6134
|
+
providerModelId: "gemini-omni-1.2-flash",
|
|
6135
|
+
lifecycle: "active",
|
|
6136
|
+
exposure: ["cowork", "space_builder"],
|
|
6137
|
+
constraints: {
|
|
6138
|
+
aspectRatios: [...OMNI_RATIOS],
|
|
6139
|
+
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
6140
|
+
durations: { min: 3, max: 15 },
|
|
6141
|
+
durationPresets: [3, 5, 8, 10, 15],
|
|
6142
|
+
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
6143
|
+
sourceVideoSeconds: { max: 15 },
|
|
6144
|
+
supports: ["videoExtension", "lastFrame"],
|
|
6145
|
+
extension: { segmentSeconds: 10, maxTotalSeconds: 30, returns: "joined" },
|
|
6146
|
+
prompt: OMNI_PROMPT,
|
|
6147
|
+
audio: "always"
|
|
6148
|
+
},
|
|
6149
|
+
defaults: {},
|
|
6150
|
+
usage: { ...VIDEO_USAGE3 },
|
|
6151
|
+
pricingKind: "video_per_second",
|
|
6152
|
+
display: {
|
|
6153
|
+
provider: "google",
|
|
6154
|
+
logo: GOOGLE_LOGO3,
|
|
6155
|
+
description: "Google Gemini Omni Flash 1.2 conversational video generation, editing and extension; text, image, and up to 15-second video input, 3-15 second output at up to 4K and 24 FPS (start and end frames up to 10 seconds), extendable to 30 seconds."
|
|
6156
|
+
},
|
|
6157
|
+
capabilities: {
|
|
6158
|
+
acceptsSourceVideo: true,
|
|
6159
|
+
videoEdit: true,
|
|
6160
|
+
lastFrameRequiresFirstFrame: true
|
|
6161
|
+
}
|
|
6162
|
+
},
|
|
6104
6163
|
{
|
|
6105
6164
|
// vibe-triggers and Space Builder drop the ratio when a frame is wired; Cowork always sends it.
|
|
6106
6165
|
id: "seedance-2.0",
|
|
@@ -7960,7 +8019,20 @@ var AspectRatioSchema = import_zod3.z.enum([
|
|
|
7960
8019
|
var ImageSizeSchema = import_zod3.z.enum(["512", "1K", "2K", "4K"]);
|
|
7961
8020
|
var VideoResolutionSchema = import_zod3.z.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
|
|
7962
8021
|
var ImageQualitySchema = import_zod3.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
|
|
7963
|
-
var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp"]);
|
|
8022
|
+
var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp", "gif", "svg"]);
|
|
8023
|
+
var ImageBackgroundSchema = import_zod3.z.enum(["auto", "opaque", "transparent"]);
|
|
8024
|
+
var AnimationLimitsSchema = import_zod3.z.looseObject({
|
|
8025
|
+
frameSizes: import_zod3.z.array(
|
|
8026
|
+
import_zod3.z.looseObject({
|
|
8027
|
+
size: import_zod3.z.string().regex(/^\d+x\d+$/u),
|
|
8028
|
+
minFrames: import_zod3.z.number().int().positive(),
|
|
8029
|
+
maxFrames: import_zod3.z.number().int().positive()
|
|
8030
|
+
})
|
|
8031
|
+
).min(1),
|
|
8032
|
+
frameDurationMs: import_zod3.z.looseObject({ min: import_zod3.z.number().positive(), max: import_zod3.z.number().positive() }),
|
|
8033
|
+
defaultFrameCount: import_zod3.z.number().int().positive(),
|
|
8034
|
+
defaultFrameDurationMs: import_zod3.z.number().positive()
|
|
8035
|
+
});
|
|
7964
8036
|
var RequiredInputSchema = import_zod3.z.enum(["firstFrame", "sourceVideo", "references", "sourceAudio"]);
|
|
7965
8037
|
var SupportedOptionSchema = import_zod3.z.enum([
|
|
7966
8038
|
"seed",
|
|
@@ -8114,6 +8186,10 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
|
|
|
8114
8186
|
}).optional(),
|
|
8115
8187
|
languages: import_zod3.z.array(LanguageOptionSchema).optional(),
|
|
8116
8188
|
outputFormats: import_zod3.z.array(import_zod3.z.string().min(1)).min(1).optional(),
|
|
8189
|
+
imageFormats: import_zod3.z.array(OutputFormatSchema).min(1).optional(),
|
|
8190
|
+
backgrounds: import_zod3.z.array(ImageBackgroundSchema).min(1).optional(),
|
|
8191
|
+
animation: AnimationLimitsSchema.optional(),
|
|
8192
|
+
svgModel: import_zod3.z.string().min(1).optional(),
|
|
8117
8193
|
sourceVideoPixels: VideoPixelLimitsSchema.optional(),
|
|
8118
8194
|
sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: import_zod3.z.boolean().optional() }).optional(),
|
|
8119
8195
|
// segmentSeconds/maxTotalSeconds stay required: a kit before 0.3.0 drops a row whose
|
|
@@ -8873,6 +8949,155 @@ function shrinkToShortEdge(width, height, limit) {
|
|
|
8873
8949
|
return { width: Math.round(width * scale), height: Math.round(height * scale) };
|
|
8874
8950
|
}
|
|
8875
8951
|
|
|
8952
|
+
// src/resolve-image-output.ts
|
|
8953
|
+
var BASE_FORMATS = ["png", "jpeg", "webp"];
|
|
8954
|
+
var ONE_K_FRAME_PIXELS = 288 * 512;
|
|
8955
|
+
function imageOutputFormats(model) {
|
|
8956
|
+
return model.constraints.imageFormats ?? BASE_FORMATS;
|
|
8957
|
+
}
|
|
8958
|
+
function animationTier(model, frameSize) {
|
|
8959
|
+
const [w, h] = frameSize.split("x").map(Number);
|
|
8960
|
+
const tier = (w ?? 0) * (h ?? 0) <= ONE_K_FRAME_PIXELS ? "1K" : "2K";
|
|
8961
|
+
const offered = model.constraints.sizes ?? ["1K", "2K", "4K"];
|
|
8962
|
+
if (offered.includes(tier)) return tier;
|
|
8963
|
+
return offered[offered.length - 1] ?? tier;
|
|
8964
|
+
}
|
|
8965
|
+
function refuse(model, message) {
|
|
8966
|
+
throw new ModelKitError({ code: "unsupported_option", message, model: model.id });
|
|
8967
|
+
}
|
|
8968
|
+
function clamp(value, min, max) {
|
|
8969
|
+
return Math.min(Math.max(value, min), max);
|
|
8970
|
+
}
|
|
8971
|
+
function applyAnimation(model, req, onUnsupported, warnings) {
|
|
8972
|
+
const limits = model.constraints.animation;
|
|
8973
|
+
if (!limits) return;
|
|
8974
|
+
const sizes = limits.frameSizes;
|
|
8975
|
+
let frameSize = sizes.find((s) => s.size === req.exactSize);
|
|
8976
|
+
if (!frameSize) {
|
|
8977
|
+
const fallback = sizes[0];
|
|
8978
|
+
if (req.exactSize !== void 0) {
|
|
8979
|
+
if (onUnsupported === "error") {
|
|
8980
|
+
refuse(
|
|
8981
|
+
model,
|
|
8982
|
+
`${model.id} makes GIF frames at ${sizes.map((s) => s.size).join(", ")}; got ${req.exactSize}`
|
|
8983
|
+
);
|
|
8984
|
+
}
|
|
8985
|
+
warnings.push({
|
|
8986
|
+
code: "option_ignored",
|
|
8987
|
+
field: "exactSize",
|
|
8988
|
+
from: req.exactSize,
|
|
8989
|
+
to: fallback.size,
|
|
8990
|
+
message: `${model.id} has no ${req.exactSize} GIF frame; using ${fallback.size}`
|
|
8991
|
+
});
|
|
8992
|
+
}
|
|
8993
|
+
frameSize = fallback;
|
|
8994
|
+
}
|
|
8995
|
+
req.exactSize = frameSize.size;
|
|
8996
|
+
delete req.aspectRatio;
|
|
8997
|
+
const animation = { ...req.animation };
|
|
8998
|
+
const asked = animation.frameCount;
|
|
8999
|
+
const frames = asked ?? clamp(limits.defaultFrameCount, frameSize.minFrames, frameSize.maxFrames);
|
|
9000
|
+
if (frames < frameSize.minFrames || frames > frameSize.maxFrames || !Number.isInteger(frames)) {
|
|
9001
|
+
if (onUnsupported === "error") {
|
|
9002
|
+
refuse(
|
|
9003
|
+
model,
|
|
9004
|
+
`${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; got ${frames}`
|
|
9005
|
+
);
|
|
9006
|
+
}
|
|
9007
|
+
const snapped = clamp(Math.round(frames), frameSize.minFrames, frameSize.maxFrames);
|
|
9008
|
+
warnings.push({
|
|
9009
|
+
code: "option_ignored",
|
|
9010
|
+
field: "animation.frameCount",
|
|
9011
|
+
from: frames,
|
|
9012
|
+
to: snapped,
|
|
9013
|
+
message: `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; using ${snapped}`
|
|
9014
|
+
});
|
|
9015
|
+
animation.frameCount = snapped;
|
|
9016
|
+
} else {
|
|
9017
|
+
animation.frameCount = frames;
|
|
9018
|
+
}
|
|
9019
|
+
const { min, max } = limits.frameDurationMs;
|
|
9020
|
+
const duration = animation.frameDurationMs ?? limits.defaultFrameDurationMs;
|
|
9021
|
+
if (duration < min || duration > max) {
|
|
9022
|
+
if (onUnsupported === "error") {
|
|
9023
|
+
refuse(model, `${model.id} shows each GIF frame ${min} to ${max} ms; got ${duration}`);
|
|
9024
|
+
}
|
|
9025
|
+
const snapped = clamp(duration, min, max);
|
|
9026
|
+
warnings.push({
|
|
9027
|
+
code: "option_ignored",
|
|
9028
|
+
field: "animation.frameDurationMs",
|
|
9029
|
+
from: duration,
|
|
9030
|
+
to: snapped,
|
|
9031
|
+
message: `${model.id} shows each GIF frame ${min} to ${max} ms; using ${snapped}`
|
|
9032
|
+
});
|
|
9033
|
+
animation.frameDurationMs = snapped;
|
|
9034
|
+
} else {
|
|
9035
|
+
animation.frameDurationMs = duration;
|
|
9036
|
+
}
|
|
9037
|
+
req.animation = animation;
|
|
9038
|
+
req.size = animationTier(model, frameSize.size);
|
|
9039
|
+
}
|
|
9040
|
+
function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
9041
|
+
const c = model.constraints;
|
|
9042
|
+
const format = req.outputFormat;
|
|
9043
|
+
if (format !== void 0 && !imageOutputFormats(model).includes(format)) {
|
|
9044
|
+
if (onUnsupported === "error") {
|
|
9045
|
+
refuse(
|
|
9046
|
+
model,
|
|
9047
|
+
`${model.id} does not offer outputFormat ${format}. Supported: ${imageOutputFormats(model).join(", ")}.`
|
|
9048
|
+
);
|
|
9049
|
+
}
|
|
9050
|
+
warnings.push({
|
|
9051
|
+
code: "option_ignored",
|
|
9052
|
+
field: "outputFormat",
|
|
9053
|
+
from: format,
|
|
9054
|
+
message: `${model.id} does not offer ${format}; ignored`
|
|
9055
|
+
});
|
|
9056
|
+
delete req.outputFormat;
|
|
9057
|
+
}
|
|
9058
|
+
if (req.background !== void 0 && !(c.backgrounds ?? []).includes(req.background)) {
|
|
9059
|
+
if (onUnsupported === "error") {
|
|
9060
|
+
refuse(model, `${model.id} does not offer background ${req.background}`);
|
|
9061
|
+
}
|
|
9062
|
+
warnings.push({
|
|
9063
|
+
code: "option_ignored",
|
|
9064
|
+
field: "background",
|
|
9065
|
+
from: req.background,
|
|
9066
|
+
message: `${model.id} does not offer background ${req.background}; ignored`
|
|
9067
|
+
});
|
|
9068
|
+
delete req.background;
|
|
9069
|
+
}
|
|
9070
|
+
if (req.outputFormat === "gif") {
|
|
9071
|
+
applyAnimation(model, req, onUnsupported, warnings);
|
|
9072
|
+
} else if (req.animation !== void 0) {
|
|
9073
|
+
warnings.push({
|
|
9074
|
+
code: "option_ignored",
|
|
9075
|
+
field: "animation",
|
|
9076
|
+
message: `animation applies to GIF output only; ignored`
|
|
9077
|
+
});
|
|
9078
|
+
delete req.animation;
|
|
9079
|
+
}
|
|
9080
|
+
if (req.outputFormat === "svg") {
|
|
9081
|
+
if (!c.svgModel) refuse(model, `${model.id} names no svgModel to write the SVG`);
|
|
9082
|
+
if ((req.references ?? []).length > 0) {
|
|
9083
|
+
refuse(model, `${model.label} cannot make an SVG from reference images`);
|
|
9084
|
+
}
|
|
9085
|
+
if ((req.count ?? 1) > 1) {
|
|
9086
|
+
if (onUnsupported === "error") {
|
|
9087
|
+
refuse(model, `${model.label} makes one SVG per call`);
|
|
9088
|
+
}
|
|
9089
|
+
warnings.push({
|
|
9090
|
+
code: "option_ignored",
|
|
9091
|
+
field: "count",
|
|
9092
|
+
from: req.count,
|
|
9093
|
+
to: 1,
|
|
9094
|
+
message: `${model.id} makes one SVG per call; using 1`
|
|
9095
|
+
});
|
|
9096
|
+
req.count = 1;
|
|
9097
|
+
}
|
|
9098
|
+
}
|
|
9099
|
+
}
|
|
9100
|
+
|
|
8876
9101
|
// src/resolve-lists.ts
|
|
8877
9102
|
function preview(listed2) {
|
|
8878
9103
|
const shown = listed2.slice(0, 12).join(", ");
|
|
@@ -9730,6 +9955,7 @@ function resolveImageOptions(model, request, onUnsupported = "error") {
|
|
|
9730
9955
|
"points",
|
|
9731
9956
|
"boxes"
|
|
9732
9957
|
]);
|
|
9958
|
+
applyImageOutputRules(model, merged, onUnsupported, warnings);
|
|
9733
9959
|
const factor = merged.scaleFactor;
|
|
9734
9960
|
if (factor !== void 0 && c.scaleFactors && !c.scaleFactors.includes(factor)) {
|
|
9735
9961
|
if (onUnsupported === "error") {
|
|
@@ -10066,7 +10292,7 @@ function setOrDelete(req, field, refs) {
|
|
|
10066
10292
|
else delete req[field];
|
|
10067
10293
|
}
|
|
10068
10294
|
function isImageFormat(format) {
|
|
10069
|
-
return format === "png" || format === "jpeg" || format === "webp";
|
|
10295
|
+
return format === "png" || format === "jpeg" || format === "webp" || format === "gif" || format === "svg";
|
|
10070
10296
|
}
|
|
10071
10297
|
function stripUndefined(obj) {
|
|
10072
10298
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
|
|
@@ -10273,7 +10499,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
|
|
|
10273
10499
|
}
|
|
10274
10500
|
|
|
10275
10501
|
// src/resolve-voice.ts
|
|
10276
|
-
function
|
|
10502
|
+
function refuse2(model, code, message) {
|
|
10277
10503
|
return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
|
|
10278
10504
|
}
|
|
10279
10505
|
function checkSample(model, sample, index) {
|
|
@@ -10282,7 +10508,7 @@ function checkSample(model, sample, index) {
|
|
|
10282
10508
|
if (limits === void 0 || length === void 0) return;
|
|
10283
10509
|
if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
|
|
10284
10510
|
const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
|
|
10285
|
-
throw
|
|
10511
|
+
throw refuse2(
|
|
10286
10512
|
model,
|
|
10287
10513
|
"unsupported_option",
|
|
10288
10514
|
`takes samples of ${range2}; sample ${index + 1} is ${length} s`
|
|
@@ -10291,11 +10517,11 @@ function checkSample(model, sample, index) {
|
|
|
10291
10517
|
}
|
|
10292
10518
|
function resolveVoiceCloneOptions(model, request) {
|
|
10293
10519
|
const title = request.title.trim();
|
|
10294
|
-
if (!title) throw
|
|
10295
|
-
if (request.samples.length === 0) throw
|
|
10520
|
+
if (!title) throw refuse2(model, "missing_input", "needs a title");
|
|
10521
|
+
if (request.samples.length === 0) throw refuse2(model, "missing_input", "needs a voice sample");
|
|
10296
10522
|
const max = model.constraints.references?.audios;
|
|
10297
10523
|
if (max !== void 0 && request.samples.length > max) {
|
|
10298
|
-
throw
|
|
10524
|
+
throw refuse2(
|
|
10299
10525
|
model,
|
|
10300
10526
|
"unsupported_option",
|
|
10301
10527
|
`takes up to ${max} samples; got ${request.samples.length}`
|
|
@@ -10305,7 +10531,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10305
10531
|
const total = model.constraints.references?.audioSeconds?.total;
|
|
10306
10532
|
const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
|
|
10307
10533
|
if (total !== void 0 && seconds3 > total) {
|
|
10308
|
-
throw
|
|
10534
|
+
throw refuse2(
|
|
10309
10535
|
model,
|
|
10310
10536
|
"unsupported_option",
|
|
10311
10537
|
`takes up to ${total} s of samples; got ${seconds3} s`
|
|
@@ -10314,7 +10540,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10314
10540
|
for (const field of ["transcript", "designSignature"]) {
|
|
10315
10541
|
const set = request.samples.filter((s) => s[field]?.trim()).length;
|
|
10316
10542
|
if (set !== 0 && set !== request.samples.length) {
|
|
10317
|
-
throw
|
|
10543
|
+
throw refuse2(model, "missing_input", `needs ${field} on every sample or on none`);
|
|
10318
10544
|
}
|
|
10319
10545
|
}
|
|
10320
10546
|
return { request: { ...request, model: model.id, title }, warnings: [] };
|
|
@@ -10322,10 +10548,10 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10322
10548
|
function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
10323
10549
|
const warnings = [];
|
|
10324
10550
|
const prompt = request.prompt.trim();
|
|
10325
|
-
if (!prompt) throw
|
|
10551
|
+
if (!prompt) throw refuse2(model, "missing_input", "needs a voice description");
|
|
10326
10552
|
const maxChars = promptConventions(model).maxChars;
|
|
10327
10553
|
if (maxChars !== void 0 && prompt.length > maxChars) {
|
|
10328
|
-
throw
|
|
10554
|
+
throw refuse2(
|
|
10329
10555
|
model,
|
|
10330
10556
|
"unsupported_option",
|
|
10331
10557
|
`takes up to ${maxChars} characters; got ${prompt.length}`
|
|
@@ -10336,7 +10562,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
10336
10562
|
const preview2 = request.previewText?.trim();
|
|
10337
10563
|
if (preview2) {
|
|
10338
10564
|
if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
|
|
10339
|
-
throw
|
|
10565
|
+
throw refuse2(
|
|
10340
10566
|
model,
|
|
10341
10567
|
"unsupported_option",
|
|
10342
10568
|
`takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
|
|
@@ -10352,7 +10578,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
10352
10578
|
const cap = limits?.maxCandidates ?? count2;
|
|
10353
10579
|
if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
|
|
10354
10580
|
if (onUnsupported === "error" || !Number.isInteger(count2)) {
|
|
10355
|
-
throw
|
|
10581
|
+
throw refuse2(
|
|
10356
10582
|
model,
|
|
10357
10583
|
"unsupported_option",
|
|
10358
10584
|
`returns 1-${cap} candidates; got ${count2}`
|