fix: advertise verified vip98k image sizes

This commit is contained in:
134 2026-09-10 16:32:25 +08:00
parent a1973ae202
commit a7d994d93b
2 changed files with 40 additions and 4 deletions

View File

@ -113,7 +113,7 @@ const DEFAULT_ASPECT_RATIOS = [
] as const;
const DEFAULT_VIDEO_RATIOS = ["16:9", "9:16", "1:1", "4:3", "3:4"] as const;
const DEFAULT_IMAGE_SIZES = ["1K", "2K", "4K"] as const;
const DEFAULT_IMAGE_SIZE = "1K";
const TYPE_SORT_ORDER: Record<string, number> = {
image: 100,
@ -505,6 +505,13 @@ function normalizeImageSize(value: string): string | null {
}
const kMatch = normalized.match(/^(\d+(?:\.\d+)?)\s*K$/);
if (kMatch?.[1]) return `${Number(kMatch[1]).toString()}K`;
const pixelMatch = normalized.match(/^(\d+)\s*[X*×]\s*(\d+)$/);
if (pixelMatch?.[1] && pixelMatch[2]) {
const longestEdge = Math.max(Number(pixelMatch[1]), Number(pixelMatch[2]));
if (longestEdge <= 1024) return "1K";
if (longestEdge <= 2048) return "2K";
if (longestEdge <= 4096) return "4K";
}
return null;
}
@ -528,10 +535,17 @@ function getSupportedResolutions(model: Vip98kCatalogModel) {
}
function getSupportedImageSizes(model: Vip98kCatalogModel) {
const sizes = getSupportedResolutions(model)
const schemaSizes = getInvocationCandidates(model).flatMap((invocation) => {
const properties =
toRecord(toRecord(invocation.input_schema)?.properties) || {};
return ["size", "image_size", "imageSize", "resolution"].flatMap(
(key) => parseStringArray(toRecord(properties[key])?.enum),
);
});
const sizes = [...getSupportedResolutions(model), ...schemaSizes]
.map(normalizeImageSize)
.filter((value): value is string => Boolean(value));
return sizes.length ? sizes : [...DEFAULT_IMAGE_SIZES];
return sizes.length ? Array.from(new Set(sizes)) : [DEFAULT_IMAGE_SIZE];
}
function getSupportedVideoResolutions(model: Vip98kCatalogModel) {

View File

@ -479,7 +479,15 @@ test.describe("VIP98K reference-image routing", () => {
aspect_ratio: { type: "string" },
file_urls: { type: "array", maxItems: 8 },
resolution: { type: "string" },
size: { type: "string", enum: ["auto", "1024x1024"] },
size: {
type: "string",
enum: [
"auto",
"1024x1024",
"2048x2048",
"4096x4096",
],
},
},
},
result_method: "GET",
@ -589,6 +597,12 @@ test.describe("VIP98K reference-image routing", () => {
n: 1,
prompt: "Generate",
},
input_schema: {
properties: {
image: { type: "array" },
size: { type: "string" },
},
},
},
},
]);
@ -601,6 +615,14 @@ test.describe("VIP98K reference-image routing", () => {
capabilities: {
supportsMultiImageReference: true,
maxReferenceImages: 8,
supportedImageSizes: ["1K"],
},
imageGenConfig: {
supportsSize: true,
supports1K: true,
supports2K: false,
supports4K: false,
supportedImageSizes: ["1K"],
},
});
});