fix(baoyu-imagine): tighten Replicate schema validation and fallback handling
This commit is contained in:
parent
7b3214e27a
commit
0ec35bf930
|
|
@ -162,6 +162,7 @@ test("Replicate input builder maps Wan models to their native schema", () => {
|
|||
size: "2K",
|
||||
num_outputs: 2,
|
||||
images: ["data:image/png;base64,AAAA"],
|
||||
thinking_mode: false,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -214,6 +215,16 @@ test("Replicate validation catches unsupported Seedream and Wan argument combina
|
|||
/Seedream on Replicate requires --size to be one of 2K, 3K/,
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
() => validateArgs("bytedance/seedream-4.5", makeArgs({ referenceImages: Array.from({ length: 15 }, () => "ref.png") })),
|
||||
/supports at most 14 reference images/,
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
() => validateArgs("bytedance/seedream-5-lite", makeArgs({ referenceImages: Array.from({ length: 10 }, () => "ref.png"), n: 10 })),
|
||||
/allows at most 15 total images per request/,
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
() => validateArgs("google/nano-banana-2", makeArgs({ n: 2 })),
|
||||
/Nano Banana models on Replicate do not support --n yet/,
|
||||
|
|
|
|||
|
|
@ -196,10 +196,8 @@ function buildWanInput(prompt: string, model: string, args: CliArgs, referenceIm
|
|||
}
|
||||
|
||||
// thinking_mode only applies to pure text-to-image.
|
||||
// image_set_mode is not exposed by the current CLI, so no extra check is needed here yet.
|
||||
if (referenceImages.length === 0) {
|
||||
input.thinking_mode = true;
|
||||
}
|
||||
// image_set_mode is not exposed by the current CLI, so switch only on input-image presence for now.
|
||||
input.thinking_mode = referenceImages.length === 0;
|
||||
|
||||
return input;
|
||||
}
|
||||
|
|
@ -216,6 +214,8 @@ export function validateArgs(model: string, args: CliArgs): void {
|
|||
}
|
||||
|
||||
if (isSeedreamModel(model)) {
|
||||
const referenceCount = args.referenceImages.length;
|
||||
|
||||
if (args.size) {
|
||||
const normalizedSize = normalizePresetSize(args.size);
|
||||
if (!getAllowedSeedreamSizes(model).has(normalizedSize)) {
|
||||
|
|
@ -225,9 +225,19 @@ export function validateArgs(model: string, args: CliArgs): void {
|
|||
}
|
||||
}
|
||||
|
||||
if (referenceCount > 14) {
|
||||
throw new Error("Seedream on Replicate supports at most 14 reference images per request.");
|
||||
}
|
||||
|
||||
if (args.n < 1 || args.n > 15) {
|
||||
throw new Error("Seedream on Replicate supports --n values from 1 to 15.");
|
||||
}
|
||||
|
||||
if (referenceCount + args.n > 15) {
|
||||
throw new Error(
|
||||
`Seedream on Replicate allows at most 15 total images per request (reference images + generated images). Received ${referenceCount} reference images and --n ${args.n}.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isWanModel(model)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue