@shop-os/modelkit 0.17.0 → 0.18.0
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 +21 -0
- package/dist/catalog.cjs +271 -13
- 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 +271 -13
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +350 -62
- 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 +348 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,27 @@ header in the release PR.
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.18.0] - Unreleased
|
|
13
|
+
|
|
14
|
+
GPT Image 2.6 output options: format, background and animated GIF.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- `ImageRequest.background` (`auto` | `opaque` | `transparent`), offered where `constraints.backgrounds` lists the value. The `openai-image` adapter sends it as `background`.
|
|
18
|
+
- `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.
|
|
19
|
+
- 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`.
|
|
20
|
+
- 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.
|
|
21
|
+
- `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.
|
|
22
|
+
- Exports `animationTier(model, frameSize)` and `imageOutputFormats`.
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
## [0.17.1] - Unreleased
|
|
27
|
+
|
|
28
|
+
GPT Image 2.6 rows in the snapshot (ENG-3735).
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- `gpt-image-2.6-sunburst` and `gpt-image-2.6-flare` (`openai-image`): the same Images API surface as the 2.5 rows (sizes 1K/2K/4K, qualities auto to max, 16 reference images), live-checked 2026-11-05. The rows went live as data-only catalog rows first; the snapshot lets pro-backend seed their pricing and catalog rows on a new environment. No `sortOrder` or `recommended`: those stay in the database.
|
|
32
|
+
|
|
12
33
|
## [0.17.0] - Unreleased
|
|
13
34
|
|
|
14
35
|
Kling 4.0 Flash on fal (ENG-3743).
|
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" };
|
|
@@ -668,6 +687,78 @@ var IMAGE_MODELS = [
|
|
|
668
687
|
logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/1204b494-8962-4f7f-af5e-699a8bdc98e3_compressed.png"
|
|
669
688
|
}
|
|
670
689
|
},
|
|
690
|
+
{
|
|
691
|
+
// Same Images API surface as gpt-image-2.5 (live-checked 2026-11-05; 2.6 also takes a `complexity` field the kit does not send).
|
|
692
|
+
id: "gpt-image-2.6-sunburst",
|
|
693
|
+
aliases: [],
|
|
694
|
+
label: "GPT Image 2.6 Sunburst",
|
|
695
|
+
type: "image",
|
|
696
|
+
adapter: "openai-image",
|
|
697
|
+
providerModelId: "gpt-image-2.6-sunburst",
|
|
698
|
+
lifecycle: "active",
|
|
699
|
+
exposure: ["cowork", "space_builder"],
|
|
700
|
+
constraints: {
|
|
701
|
+
exactSizes: {
|
|
702
|
+
"1:1": "1024x1024",
|
|
703
|
+
"3:2": "1536x1024",
|
|
704
|
+
"2:3": "1024x1536",
|
|
705
|
+
"16:9": "2048x1152",
|
|
706
|
+
"9:16": "1152x2048",
|
|
707
|
+
"4:5": "1024x1280",
|
|
708
|
+
"5:4": "1280x1024"
|
|
709
|
+
},
|
|
710
|
+
aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
|
|
711
|
+
sizes: ["1K", "2K", "4K"],
|
|
712
|
+
qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
|
|
713
|
+
references: { images: 16 },
|
|
714
|
+
supports: ["quality", "count", "outputFormat"],
|
|
715
|
+
prompt: GPT_IMAGE_PROMPT,
|
|
716
|
+
...GPT_IMAGE_2_6_OUTPUT
|
|
717
|
+
},
|
|
718
|
+
defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
|
|
719
|
+
usage: { ...IMAGE_USAGE3 },
|
|
720
|
+
pricingKind: "image_size",
|
|
721
|
+
display: {
|
|
722
|
+
provider: "openai",
|
|
723
|
+
description: "OpenAI's most detailed GPT Image 2.6 tier, built for intricate detail and editing precision; takes text and image input and outputs images in low, medium, high, xhigh, or max quality."
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
// Same Images API surface as gpt-image-2.5 (live-checked 2026-11-05; 2.6 also takes a `complexity` field the kit does not send).
|
|
728
|
+
id: "gpt-image-2.6-flare",
|
|
729
|
+
aliases: [],
|
|
730
|
+
label: "GPT Image 2.6 Flare",
|
|
731
|
+
type: "image",
|
|
732
|
+
adapter: "openai-image",
|
|
733
|
+
providerModelId: "gpt-image-2.6-flare",
|
|
734
|
+
lifecycle: "active",
|
|
735
|
+
exposure: ["cowork", "space_builder"],
|
|
736
|
+
constraints: {
|
|
737
|
+
exactSizes: {
|
|
738
|
+
"1:1": "1024x1024",
|
|
739
|
+
"3:2": "1536x1024",
|
|
740
|
+
"2:3": "1024x1536",
|
|
741
|
+
"16:9": "2048x1152",
|
|
742
|
+
"9:16": "1152x2048",
|
|
743
|
+
"4:5": "1024x1280",
|
|
744
|
+
"5:4": "1280x1024"
|
|
745
|
+
},
|
|
746
|
+
aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
|
|
747
|
+
sizes: ["1K", "2K", "4K"],
|
|
748
|
+
qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
|
|
749
|
+
references: { images: 16 },
|
|
750
|
+
supports: ["quality", "count", "outputFormat"],
|
|
751
|
+
prompt: GPT_IMAGE_PROMPT,
|
|
752
|
+
...GPT_IMAGE_2_6_OUTPUT
|
|
753
|
+
},
|
|
754
|
+
defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
|
|
755
|
+
usage: { ...IMAGE_USAGE3 },
|
|
756
|
+
pricingKind: "image_size",
|
|
757
|
+
display: {
|
|
758
|
+
provider: "openai",
|
|
759
|
+
description: "OpenAI's fast GPT Image 2.6 tier for everyday image generation and editing, with natural lighting, rich textures and complex layouts; takes text and image input and outputs images in low, medium, high, xhigh, or max quality."
|
|
760
|
+
}
|
|
761
|
+
},
|
|
671
762
|
{
|
|
672
763
|
// Same Images API surface as gpt-image-2 plus the "xhigh" and "max" quality tiers.
|
|
673
764
|
id: "gpt-image-2.5-sunburst",
|
|
@@ -7890,7 +7981,20 @@ var AspectRatioSchema = import_zod3.z.enum([
|
|
|
7890
7981
|
var ImageSizeSchema = import_zod3.z.enum(["512", "1K", "2K", "4K"]);
|
|
7891
7982
|
var VideoResolutionSchema = import_zod3.z.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
|
|
7892
7983
|
var ImageQualitySchema = import_zod3.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
|
|
7893
|
-
var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp"]);
|
|
7984
|
+
var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp", "gif", "svg"]);
|
|
7985
|
+
var ImageBackgroundSchema = import_zod3.z.enum(["auto", "opaque", "transparent"]);
|
|
7986
|
+
var AnimationLimitsSchema = import_zod3.z.looseObject({
|
|
7987
|
+
frameSizes: import_zod3.z.array(
|
|
7988
|
+
import_zod3.z.looseObject({
|
|
7989
|
+
size: import_zod3.z.string().regex(/^\d+x\d+$/u),
|
|
7990
|
+
minFrames: import_zod3.z.number().int().positive(),
|
|
7991
|
+
maxFrames: import_zod3.z.number().int().positive()
|
|
7992
|
+
})
|
|
7993
|
+
).min(1),
|
|
7994
|
+
frameDurationMs: import_zod3.z.looseObject({ min: import_zod3.z.number().positive(), max: import_zod3.z.number().positive() }),
|
|
7995
|
+
defaultFrameCount: import_zod3.z.number().int().positive(),
|
|
7996
|
+
defaultFrameDurationMs: import_zod3.z.number().positive()
|
|
7997
|
+
});
|
|
7894
7998
|
var RequiredInputSchema = import_zod3.z.enum(["firstFrame", "sourceVideo", "references", "sourceAudio"]);
|
|
7895
7999
|
var SupportedOptionSchema = import_zod3.z.enum([
|
|
7896
8000
|
"seed",
|
|
@@ -8044,6 +8148,10 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
|
|
|
8044
8148
|
}).optional(),
|
|
8045
8149
|
languages: import_zod3.z.array(LanguageOptionSchema).optional(),
|
|
8046
8150
|
outputFormats: import_zod3.z.array(import_zod3.z.string().min(1)).min(1).optional(),
|
|
8151
|
+
imageFormats: import_zod3.z.array(OutputFormatSchema).min(1).optional(),
|
|
8152
|
+
backgrounds: import_zod3.z.array(ImageBackgroundSchema).min(1).optional(),
|
|
8153
|
+
animation: AnimationLimitsSchema.optional(),
|
|
8154
|
+
svgModel: import_zod3.z.string().min(1).optional(),
|
|
8047
8155
|
sourceVideoPixels: VideoPixelLimitsSchema.optional(),
|
|
8048
8156
|
sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: import_zod3.z.boolean().optional() }).optional(),
|
|
8049
8157
|
// segmentSeconds/maxTotalSeconds stay required: a kit before 0.3.0 drops a row whose
|
|
@@ -8803,6 +8911,155 @@ function shrinkToShortEdge(width, height, limit) {
|
|
|
8803
8911
|
return { width: Math.round(width * scale), height: Math.round(height * scale) };
|
|
8804
8912
|
}
|
|
8805
8913
|
|
|
8914
|
+
// src/resolve-image-output.ts
|
|
8915
|
+
var BASE_FORMATS = ["png", "jpeg", "webp"];
|
|
8916
|
+
var ONE_K_FRAME_PIXELS = 288 * 512;
|
|
8917
|
+
function imageOutputFormats(model) {
|
|
8918
|
+
return model.constraints.imageFormats ?? BASE_FORMATS;
|
|
8919
|
+
}
|
|
8920
|
+
function animationTier(model, frameSize) {
|
|
8921
|
+
const [w, h] = frameSize.split("x").map(Number);
|
|
8922
|
+
const tier = (w ?? 0) * (h ?? 0) <= ONE_K_FRAME_PIXELS ? "1K" : "2K";
|
|
8923
|
+
const offered = model.constraints.sizes ?? ["1K", "2K", "4K"];
|
|
8924
|
+
if (offered.includes(tier)) return tier;
|
|
8925
|
+
return offered[offered.length - 1] ?? tier;
|
|
8926
|
+
}
|
|
8927
|
+
function refuse(model, message) {
|
|
8928
|
+
throw new ModelKitError({ code: "unsupported_option", message, model: model.id });
|
|
8929
|
+
}
|
|
8930
|
+
function clamp(value, min, max) {
|
|
8931
|
+
return Math.min(Math.max(value, min), max);
|
|
8932
|
+
}
|
|
8933
|
+
function applyAnimation(model, req, onUnsupported, warnings) {
|
|
8934
|
+
const limits = model.constraints.animation;
|
|
8935
|
+
if (!limits) return;
|
|
8936
|
+
const sizes = limits.frameSizes;
|
|
8937
|
+
let frameSize = sizes.find((s) => s.size === req.exactSize);
|
|
8938
|
+
if (!frameSize) {
|
|
8939
|
+
const fallback = sizes[0];
|
|
8940
|
+
if (req.exactSize !== void 0) {
|
|
8941
|
+
if (onUnsupported === "error") {
|
|
8942
|
+
refuse(
|
|
8943
|
+
model,
|
|
8944
|
+
`${model.id} makes GIF frames at ${sizes.map((s) => s.size).join(", ")}; got ${req.exactSize}`
|
|
8945
|
+
);
|
|
8946
|
+
}
|
|
8947
|
+
warnings.push({
|
|
8948
|
+
code: "option_ignored",
|
|
8949
|
+
field: "exactSize",
|
|
8950
|
+
from: req.exactSize,
|
|
8951
|
+
to: fallback.size,
|
|
8952
|
+
message: `${model.id} has no ${req.exactSize} GIF frame; using ${fallback.size}`
|
|
8953
|
+
});
|
|
8954
|
+
}
|
|
8955
|
+
frameSize = fallback;
|
|
8956
|
+
}
|
|
8957
|
+
req.exactSize = frameSize.size;
|
|
8958
|
+
delete req.aspectRatio;
|
|
8959
|
+
const animation = { ...req.animation };
|
|
8960
|
+
const asked = animation.frameCount;
|
|
8961
|
+
const frames = asked ?? clamp(limits.defaultFrameCount, frameSize.minFrames, frameSize.maxFrames);
|
|
8962
|
+
if (frames < frameSize.minFrames || frames > frameSize.maxFrames || !Number.isInteger(frames)) {
|
|
8963
|
+
if (onUnsupported === "error") {
|
|
8964
|
+
refuse(
|
|
8965
|
+
model,
|
|
8966
|
+
`${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; got ${frames}`
|
|
8967
|
+
);
|
|
8968
|
+
}
|
|
8969
|
+
const snapped = clamp(Math.round(frames), frameSize.minFrames, frameSize.maxFrames);
|
|
8970
|
+
warnings.push({
|
|
8971
|
+
code: "option_ignored",
|
|
8972
|
+
field: "animation.frameCount",
|
|
8973
|
+
from: frames,
|
|
8974
|
+
to: snapped,
|
|
8975
|
+
message: `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; using ${snapped}`
|
|
8976
|
+
});
|
|
8977
|
+
animation.frameCount = snapped;
|
|
8978
|
+
} else {
|
|
8979
|
+
animation.frameCount = frames;
|
|
8980
|
+
}
|
|
8981
|
+
const { min, max } = limits.frameDurationMs;
|
|
8982
|
+
const duration = animation.frameDurationMs ?? limits.defaultFrameDurationMs;
|
|
8983
|
+
if (duration < min || duration > max) {
|
|
8984
|
+
if (onUnsupported === "error") {
|
|
8985
|
+
refuse(model, `${model.id} shows each GIF frame ${min} to ${max} ms; got ${duration}`);
|
|
8986
|
+
}
|
|
8987
|
+
const snapped = clamp(duration, min, max);
|
|
8988
|
+
warnings.push({
|
|
8989
|
+
code: "option_ignored",
|
|
8990
|
+
field: "animation.frameDurationMs",
|
|
8991
|
+
from: duration,
|
|
8992
|
+
to: snapped,
|
|
8993
|
+
message: `${model.id} shows each GIF frame ${min} to ${max} ms; using ${snapped}`
|
|
8994
|
+
});
|
|
8995
|
+
animation.frameDurationMs = snapped;
|
|
8996
|
+
} else {
|
|
8997
|
+
animation.frameDurationMs = duration;
|
|
8998
|
+
}
|
|
8999
|
+
req.animation = animation;
|
|
9000
|
+
req.size = animationTier(model, frameSize.size);
|
|
9001
|
+
}
|
|
9002
|
+
function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
9003
|
+
const c = model.constraints;
|
|
9004
|
+
const format = req.outputFormat;
|
|
9005
|
+
if (format !== void 0 && !imageOutputFormats(model).includes(format)) {
|
|
9006
|
+
if (onUnsupported === "error") {
|
|
9007
|
+
refuse(
|
|
9008
|
+
model,
|
|
9009
|
+
`${model.id} does not offer outputFormat ${format}. Supported: ${imageOutputFormats(model).join(", ")}.`
|
|
9010
|
+
);
|
|
9011
|
+
}
|
|
9012
|
+
warnings.push({
|
|
9013
|
+
code: "option_ignored",
|
|
9014
|
+
field: "outputFormat",
|
|
9015
|
+
from: format,
|
|
9016
|
+
message: `${model.id} does not offer ${format}; ignored`
|
|
9017
|
+
});
|
|
9018
|
+
delete req.outputFormat;
|
|
9019
|
+
}
|
|
9020
|
+
if (req.background !== void 0 && !(c.backgrounds ?? []).includes(req.background)) {
|
|
9021
|
+
if (onUnsupported === "error") {
|
|
9022
|
+
refuse(model, `${model.id} does not offer background ${req.background}`);
|
|
9023
|
+
}
|
|
9024
|
+
warnings.push({
|
|
9025
|
+
code: "option_ignored",
|
|
9026
|
+
field: "background",
|
|
9027
|
+
from: req.background,
|
|
9028
|
+
message: `${model.id} does not offer background ${req.background}; ignored`
|
|
9029
|
+
});
|
|
9030
|
+
delete req.background;
|
|
9031
|
+
}
|
|
9032
|
+
if (req.outputFormat === "gif") {
|
|
9033
|
+
applyAnimation(model, req, onUnsupported, warnings);
|
|
9034
|
+
} else if (req.animation !== void 0) {
|
|
9035
|
+
warnings.push({
|
|
9036
|
+
code: "option_ignored",
|
|
9037
|
+
field: "animation",
|
|
9038
|
+
message: `animation applies to GIF output only; ignored`
|
|
9039
|
+
});
|
|
9040
|
+
delete req.animation;
|
|
9041
|
+
}
|
|
9042
|
+
if (req.outputFormat === "svg") {
|
|
9043
|
+
if (!c.svgModel) refuse(model, `${model.id} names no svgModel to write the SVG`);
|
|
9044
|
+
if ((req.references ?? []).length > 0) {
|
|
9045
|
+
refuse(model, `${model.label} cannot make an SVG from reference images`);
|
|
9046
|
+
}
|
|
9047
|
+
if ((req.count ?? 1) > 1) {
|
|
9048
|
+
if (onUnsupported === "error") {
|
|
9049
|
+
refuse(model, `${model.label} makes one SVG per call`);
|
|
9050
|
+
}
|
|
9051
|
+
warnings.push({
|
|
9052
|
+
code: "option_ignored",
|
|
9053
|
+
field: "count",
|
|
9054
|
+
from: req.count,
|
|
9055
|
+
to: 1,
|
|
9056
|
+
message: `${model.id} makes one SVG per call; using 1`
|
|
9057
|
+
});
|
|
9058
|
+
req.count = 1;
|
|
9059
|
+
}
|
|
9060
|
+
}
|
|
9061
|
+
}
|
|
9062
|
+
|
|
8806
9063
|
// src/resolve-lists.ts
|
|
8807
9064
|
function preview(listed2) {
|
|
8808
9065
|
const shown = listed2.slice(0, 12).join(", ");
|
|
@@ -9660,6 +9917,7 @@ function resolveImageOptions(model, request, onUnsupported = "error") {
|
|
|
9660
9917
|
"points",
|
|
9661
9918
|
"boxes"
|
|
9662
9919
|
]);
|
|
9920
|
+
applyImageOutputRules(model, merged, onUnsupported, warnings);
|
|
9663
9921
|
const factor = merged.scaleFactor;
|
|
9664
9922
|
if (factor !== void 0 && c.scaleFactors && !c.scaleFactors.includes(factor)) {
|
|
9665
9923
|
if (onUnsupported === "error") {
|
|
@@ -9996,7 +10254,7 @@ function setOrDelete(req, field, refs) {
|
|
|
9996
10254
|
else delete req[field];
|
|
9997
10255
|
}
|
|
9998
10256
|
function isImageFormat(format) {
|
|
9999
|
-
return format === "png" || format === "jpeg" || format === "webp";
|
|
10257
|
+
return format === "png" || format === "jpeg" || format === "webp" || format === "gif" || format === "svg";
|
|
10000
10258
|
}
|
|
10001
10259
|
function stripUndefined(obj) {
|
|
10002
10260
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
|
|
@@ -10203,7 +10461,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
|
|
|
10203
10461
|
}
|
|
10204
10462
|
|
|
10205
10463
|
// src/resolve-voice.ts
|
|
10206
|
-
function
|
|
10464
|
+
function refuse2(model, code, message) {
|
|
10207
10465
|
return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
|
|
10208
10466
|
}
|
|
10209
10467
|
function checkSample(model, sample, index) {
|
|
@@ -10212,7 +10470,7 @@ function checkSample(model, sample, index) {
|
|
|
10212
10470
|
if (limits === void 0 || length === void 0) return;
|
|
10213
10471
|
if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
|
|
10214
10472
|
const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
|
|
10215
|
-
throw
|
|
10473
|
+
throw refuse2(
|
|
10216
10474
|
model,
|
|
10217
10475
|
"unsupported_option",
|
|
10218
10476
|
`takes samples of ${range2}; sample ${index + 1} is ${length} s`
|
|
@@ -10221,11 +10479,11 @@ function checkSample(model, sample, index) {
|
|
|
10221
10479
|
}
|
|
10222
10480
|
function resolveVoiceCloneOptions(model, request) {
|
|
10223
10481
|
const title = request.title.trim();
|
|
10224
|
-
if (!title) throw
|
|
10225
|
-
if (request.samples.length === 0) throw
|
|
10482
|
+
if (!title) throw refuse2(model, "missing_input", "needs a title");
|
|
10483
|
+
if (request.samples.length === 0) throw refuse2(model, "missing_input", "needs a voice sample");
|
|
10226
10484
|
const max = model.constraints.references?.audios;
|
|
10227
10485
|
if (max !== void 0 && request.samples.length > max) {
|
|
10228
|
-
throw
|
|
10486
|
+
throw refuse2(
|
|
10229
10487
|
model,
|
|
10230
10488
|
"unsupported_option",
|
|
10231
10489
|
`takes up to ${max} samples; got ${request.samples.length}`
|
|
@@ -10235,7 +10493,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10235
10493
|
const total = model.constraints.references?.audioSeconds?.total;
|
|
10236
10494
|
const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
|
|
10237
10495
|
if (total !== void 0 && seconds3 > total) {
|
|
10238
|
-
throw
|
|
10496
|
+
throw refuse2(
|
|
10239
10497
|
model,
|
|
10240
10498
|
"unsupported_option",
|
|
10241
10499
|
`takes up to ${total} s of samples; got ${seconds3} s`
|
|
@@ -10244,7 +10502,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10244
10502
|
for (const field of ["transcript", "designSignature"]) {
|
|
10245
10503
|
const set = request.samples.filter((s) => s[field]?.trim()).length;
|
|
10246
10504
|
if (set !== 0 && set !== request.samples.length) {
|
|
10247
|
-
throw
|
|
10505
|
+
throw refuse2(model, "missing_input", `needs ${field} on every sample or on none`);
|
|
10248
10506
|
}
|
|
10249
10507
|
}
|
|
10250
10508
|
return { request: { ...request, model: model.id, title }, warnings: [] };
|
|
@@ -10252,10 +10510,10 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10252
10510
|
function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
10253
10511
|
const warnings = [];
|
|
10254
10512
|
const prompt = request.prompt.trim();
|
|
10255
|
-
if (!prompt) throw
|
|
10513
|
+
if (!prompt) throw refuse2(model, "missing_input", "needs a voice description");
|
|
10256
10514
|
const maxChars = promptConventions(model).maxChars;
|
|
10257
10515
|
if (maxChars !== void 0 && prompt.length > maxChars) {
|
|
10258
|
-
throw
|
|
10516
|
+
throw refuse2(
|
|
10259
10517
|
model,
|
|
10260
10518
|
"unsupported_option",
|
|
10261
10519
|
`takes up to ${maxChars} characters; got ${prompt.length}`
|
|
@@ -10266,7 +10524,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
10266
10524
|
const preview2 = request.previewText?.trim();
|
|
10267
10525
|
if (preview2) {
|
|
10268
10526
|
if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
|
|
10269
|
-
throw
|
|
10527
|
+
throw refuse2(
|
|
10270
10528
|
model,
|
|
10271
10529
|
"unsupported_option",
|
|
10272
10530
|
`takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
|
|
@@ -10282,7 +10540,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
10282
10540
|
const cap = limits?.maxCandidates ?? count2;
|
|
10283
10541
|
if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
|
|
10284
10542
|
if (onUnsupported === "error" || !Number.isInteger(count2)) {
|
|
10285
|
-
throw
|
|
10543
|
+
throw refuse2(
|
|
10286
10544
|
model,
|
|
10287
10545
|
"unsupported_option",
|
|
10288
10546
|
`returns 1-${cap} candidates; got ${count2}`
|