fix(baoyu-image-gen): narrow OpenRouter Gemini ratios
This commit is contained in:
parent
96ef6e2251
commit
e43eec260a
|
|
@ -12,6 +12,7 @@ import {
|
|||
} from "./openrouter.ts";
|
||||
|
||||
const GEMINI_MODEL = "google/gemini-3.1-flash-image-preview";
|
||||
const GEMINI_25_MODEL = "google/gemini-2.5-flash-image-preview";
|
||||
const FLUX_MODEL = "black-forest-labs/flux.2-pro";
|
||||
|
||||
function makeArgs(overrides: Partial<CliArgs> = {}): CliArgs {
|
||||
|
|
@ -78,6 +79,7 @@ test("OpenRouter size and aspect helpers infer expected defaults", () => {
|
|||
assert.equal(getAspectRatio(GEMINI_MODEL, makeArgs({ size: "2048x1024" })), null);
|
||||
assert.equal(getAspectRatio(GEMINI_MODEL, makeArgs({ size: "1600x900" })), "16:9");
|
||||
assert.equal(getAspectRatio(GEMINI_MODEL, makeArgs({ size: "1024x4096" })), "1:4");
|
||||
assert.equal(getAspectRatio(GEMINI_25_MODEL, makeArgs({ size: "1024x4096" })), null);
|
||||
assert.equal(getAspectRatio(FLUX_MODEL, makeArgs({ size: "1024x4096" })), null);
|
||||
});
|
||||
|
||||
|
|
@ -85,6 +87,10 @@ test("OpenRouter validates explicit aspect ratios against model support", () =>
|
|||
assert.doesNotThrow(() =>
|
||||
validateArgs(GEMINI_MODEL, makeArgs({ aspectRatio: "1:4" })),
|
||||
);
|
||||
assert.throws(
|
||||
() => validateArgs(GEMINI_25_MODEL, makeArgs({ aspectRatio: "1:4" })),
|
||||
/does not support aspect ratio 1:4/,
|
||||
);
|
||||
assert.throws(
|
||||
() => validateArgs(FLUX_MODEL, makeArgs({ aspectRatio: "1:4" })),
|
||||
/does not support aspect ratio 1:4/,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export function getDefaultModel(): string {
|
|||
}
|
||||
|
||||
function normalizeModelId(model: string): string {
|
||||
return model.trim().toLowerCase();
|
||||
return model.trim().toLowerCase().split(":")[0]!;
|
||||
}
|
||||
|
||||
export function isGeminiImageModel(model: string): boolean {
|
||||
|
|
@ -54,7 +54,8 @@ export function isGeminiImageModel(model: string): boolean {
|
|||
}
|
||||
|
||||
function getSupportedAspectRatios(model: string): Set<string> {
|
||||
if (!isGeminiImageModel(model)) {
|
||||
const normalized = normalizeModelId(model);
|
||||
if (normalized !== "google/gemini-3.1-flash-image-preview") {
|
||||
return new Set(COMMON_ASPECT_RATIOS);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue