@shop-os/modelkit 0.17.1 → 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 +14 -0
- package/dist/catalog.cjs +203 -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 +203 -15
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +282 -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 +280 -64
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,20 @@ 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
|
+
|
|
12
26
|
## [0.17.1] - Unreleased
|
|
13
27
|
|
|
14
28
|
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 },
|
|
@@ -7960,7 +7981,20 @@ var AspectRatioSchema = import_zod3.z.enum([
|
|
|
7960
7981
|
var ImageSizeSchema = import_zod3.z.enum(["512", "1K", "2K", "4K"]);
|
|
7961
7982
|
var VideoResolutionSchema = import_zod3.z.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
|
|
7962
7983
|
var ImageQualitySchema = import_zod3.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
|
|
7963
|
-
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
|
+
});
|
|
7964
7998
|
var RequiredInputSchema = import_zod3.z.enum(["firstFrame", "sourceVideo", "references", "sourceAudio"]);
|
|
7965
7999
|
var SupportedOptionSchema = import_zod3.z.enum([
|
|
7966
8000
|
"seed",
|
|
@@ -8114,6 +8148,10 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
|
|
|
8114
8148
|
}).optional(),
|
|
8115
8149
|
languages: import_zod3.z.array(LanguageOptionSchema).optional(),
|
|
8116
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(),
|
|
8117
8155
|
sourceVideoPixels: VideoPixelLimitsSchema.optional(),
|
|
8118
8156
|
sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: import_zod3.z.boolean().optional() }).optional(),
|
|
8119
8157
|
// segmentSeconds/maxTotalSeconds stay required: a kit before 0.3.0 drops a row whose
|
|
@@ -8873,6 +8911,155 @@ function shrinkToShortEdge(width, height, limit) {
|
|
|
8873
8911
|
return { width: Math.round(width * scale), height: Math.round(height * scale) };
|
|
8874
8912
|
}
|
|
8875
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
|
+
|
|
8876
9063
|
// src/resolve-lists.ts
|
|
8877
9064
|
function preview(listed2) {
|
|
8878
9065
|
const shown = listed2.slice(0, 12).join(", ");
|
|
@@ -9730,6 +9917,7 @@ function resolveImageOptions(model, request, onUnsupported = "error") {
|
|
|
9730
9917
|
"points",
|
|
9731
9918
|
"boxes"
|
|
9732
9919
|
]);
|
|
9920
|
+
applyImageOutputRules(model, merged, onUnsupported, warnings);
|
|
9733
9921
|
const factor = merged.scaleFactor;
|
|
9734
9922
|
if (factor !== void 0 && c.scaleFactors && !c.scaleFactors.includes(factor)) {
|
|
9735
9923
|
if (onUnsupported === "error") {
|
|
@@ -10066,7 +10254,7 @@ function setOrDelete(req, field, refs) {
|
|
|
10066
10254
|
else delete req[field];
|
|
10067
10255
|
}
|
|
10068
10256
|
function isImageFormat(format) {
|
|
10069
|
-
return format === "png" || format === "jpeg" || format === "webp";
|
|
10257
|
+
return format === "png" || format === "jpeg" || format === "webp" || format === "gif" || format === "svg";
|
|
10070
10258
|
}
|
|
10071
10259
|
function stripUndefined(obj) {
|
|
10072
10260
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
|
|
@@ -10273,7 +10461,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
|
|
|
10273
10461
|
}
|
|
10274
10462
|
|
|
10275
10463
|
// src/resolve-voice.ts
|
|
10276
|
-
function
|
|
10464
|
+
function refuse2(model, code, message) {
|
|
10277
10465
|
return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
|
|
10278
10466
|
}
|
|
10279
10467
|
function checkSample(model, sample, index) {
|
|
@@ -10282,7 +10470,7 @@ function checkSample(model, sample, index) {
|
|
|
10282
10470
|
if (limits === void 0 || length === void 0) return;
|
|
10283
10471
|
if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
|
|
10284
10472
|
const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
|
|
10285
|
-
throw
|
|
10473
|
+
throw refuse2(
|
|
10286
10474
|
model,
|
|
10287
10475
|
"unsupported_option",
|
|
10288
10476
|
`takes samples of ${range2}; sample ${index + 1} is ${length} s`
|
|
@@ -10291,11 +10479,11 @@ function checkSample(model, sample, index) {
|
|
|
10291
10479
|
}
|
|
10292
10480
|
function resolveVoiceCloneOptions(model, request) {
|
|
10293
10481
|
const title = request.title.trim();
|
|
10294
|
-
if (!title) throw
|
|
10295
|
-
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");
|
|
10296
10484
|
const max = model.constraints.references?.audios;
|
|
10297
10485
|
if (max !== void 0 && request.samples.length > max) {
|
|
10298
|
-
throw
|
|
10486
|
+
throw refuse2(
|
|
10299
10487
|
model,
|
|
10300
10488
|
"unsupported_option",
|
|
10301
10489
|
`takes up to ${max} samples; got ${request.samples.length}`
|
|
@@ -10305,7 +10493,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10305
10493
|
const total = model.constraints.references?.audioSeconds?.total;
|
|
10306
10494
|
const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
|
|
10307
10495
|
if (total !== void 0 && seconds3 > total) {
|
|
10308
|
-
throw
|
|
10496
|
+
throw refuse2(
|
|
10309
10497
|
model,
|
|
10310
10498
|
"unsupported_option",
|
|
10311
10499
|
`takes up to ${total} s of samples; got ${seconds3} s`
|
|
@@ -10314,7 +10502,7 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10314
10502
|
for (const field of ["transcript", "designSignature"]) {
|
|
10315
10503
|
const set = request.samples.filter((s) => s[field]?.trim()).length;
|
|
10316
10504
|
if (set !== 0 && set !== request.samples.length) {
|
|
10317
|
-
throw
|
|
10505
|
+
throw refuse2(model, "missing_input", `needs ${field} on every sample or on none`);
|
|
10318
10506
|
}
|
|
10319
10507
|
}
|
|
10320
10508
|
return { request: { ...request, model: model.id, title }, warnings: [] };
|
|
@@ -10322,10 +10510,10 @@ function resolveVoiceCloneOptions(model, request) {
|
|
|
10322
10510
|
function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
10323
10511
|
const warnings = [];
|
|
10324
10512
|
const prompt = request.prompt.trim();
|
|
10325
|
-
if (!prompt) throw
|
|
10513
|
+
if (!prompt) throw refuse2(model, "missing_input", "needs a voice description");
|
|
10326
10514
|
const maxChars = promptConventions(model).maxChars;
|
|
10327
10515
|
if (maxChars !== void 0 && prompt.length > maxChars) {
|
|
10328
|
-
throw
|
|
10516
|
+
throw refuse2(
|
|
10329
10517
|
model,
|
|
10330
10518
|
"unsupported_option",
|
|
10331
10519
|
`takes up to ${maxChars} characters; got ${prompt.length}`
|
|
@@ -10336,7 +10524,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
10336
10524
|
const preview2 = request.previewText?.trim();
|
|
10337
10525
|
if (preview2) {
|
|
10338
10526
|
if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
|
|
10339
|
-
throw
|
|
10527
|
+
throw refuse2(
|
|
10340
10528
|
model,
|
|
10341
10529
|
"unsupported_option",
|
|
10342
10530
|
`takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
|
|
@@ -10352,7 +10540,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
|
|
|
10352
10540
|
const cap = limits?.maxCandidates ?? count2;
|
|
10353
10541
|
if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
|
|
10354
10542
|
if (onUnsupported === "error" || !Number.isInteger(count2)) {
|
|
10355
|
-
throw
|
|
10543
|
+
throw refuse2(
|
|
10356
10544
|
model,
|
|
10357
10545
|
"unsupported_option",
|
|
10358
10546
|
`returns 1-${cap} candidates; got ${count2}`
|