feat(web): 模型能力 - Agnes 图像协议补充比例档位与单次张数默认值

This commit is contained in:
zhuchi
2026-09-16 20:03:46 +08:00
parent ff1a5afac5
commit 53c8a4992c
2 changed files with 38 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ import {
imageSizeForResolution,
supportsImageResolutionPresets,
} from "../src/lib/image-resolution-tiers";
import { defaultImageCapabilityConfig } from "../src/lib/model-capabilities";
import { defaultImageCapabilityConfig, normalizeImageValue } from "../src/lib/model-capabilities";
import { resolveImageRequestSize } from "../src/services/api/image-validation";
const sizes = [
@@ -65,6 +65,23 @@ describe("image resolution tiers", () => {
expect(buildImageResolutionOptions(profile.size.values)).toHaveLength(30);
});
// Agnes 图像的 size 是官方必填项,但取分辨率档位,画面比例走独立的 ratio 字段,
// 所以界面必须同时保留比例和档位两个选择器,不能退化成 OpenAI 的像素尺寸。
test("Agnes 图像按比例加档位选择尺寸,并关闭上游不支持的输出开关", () => {
const profile = defaultImageCapabilityConfig("agnes-image", "agnes-image-2.1-flash");
expect(profile.size.parameter).toBe("aspect_ratio");
expect(profile.size.values).toEqual(["1:1", "3:4", "4:3", "16:9", "9:16", "2:3", "3:2", "21:9"]);
expect(profile.quality.values).toEqual(["1k", "2k", "4k"]);
expect(normalizeImageValue(profile, { size: "3:4", quality: "4k", count: "4" })).toMatchObject({ size: "3:4", quality: "4k", count: "1" });
// 顶层 response_format 是官方明确列出的错误写法,output_format 会被上游直接拒绝。
expect(profile.responseFormat.supported).toBe(false);
expect(profile.outputFormat.supported).toBe(false);
expect(profile.transparentBackground.supported).toBe(false);
expect(profile.references.maskSupported).toBe(false);
});
test("识别适合全景图的 2:1 自定义尺寸", () => {
const options = buildImageResolutionOptions(["1440x720", "2048x1024", "3840x1920"]);