162 lines
4.4 KiB
TypeScript
162 lines
4.4 KiB
TypeScript
export interface VisionaryModelPreset {
|
|
modelId: string;
|
|
displayName: string;
|
|
description: string;
|
|
supportsVision: boolean;
|
|
supportsImageGen: boolean;
|
|
capabilities?: Record<string, any>;
|
|
defaultParams?: Record<string, any>;
|
|
imageGenConfig?: Record<string, any>;
|
|
sortOrder: number;
|
|
}
|
|
|
|
export const VISIONARY_BASE_URL = "https://api.visionary.beer";
|
|
|
|
const VISIONARY_GPT_IMAGE_RATIOS = [
|
|
"auto",
|
|
"1:1",
|
|
"3:2",
|
|
"2:3",
|
|
"4:3",
|
|
"3:4",
|
|
"16:9",
|
|
"9:16",
|
|
"21:9",
|
|
"9:21",
|
|
"2:1",
|
|
"1:2",
|
|
"5:4",
|
|
"4:5",
|
|
"3:1",
|
|
"1:3",
|
|
];
|
|
|
|
const VISIONARY_NANO_BANANA_RATIOS = [
|
|
"auto",
|
|
"1:1",
|
|
"4:3",
|
|
"3:4",
|
|
"3:2",
|
|
"2:3",
|
|
"16:9",
|
|
"9:16",
|
|
"21:9",
|
|
"5:4",
|
|
"4:5",
|
|
"1:4",
|
|
"4:1",
|
|
"1:8",
|
|
"8:1",
|
|
];
|
|
|
|
function buildVisionaryPreset(params: {
|
|
modelId: string;
|
|
displayName: string;
|
|
description: string;
|
|
supportedAspectRatios: string[];
|
|
supportedImageSizes: string[];
|
|
defaultImageSize: string;
|
|
supportsQuality?: boolean;
|
|
supportsPromptExtend?: boolean;
|
|
sortOrder: number;
|
|
}) {
|
|
const supportedModes = ["text-to-image", "image-to-image", "reference-images"];
|
|
|
|
return {
|
|
modelId: params.modelId,
|
|
displayName: params.displayName,
|
|
description: params.description,
|
|
supportsVision: true,
|
|
supportsImageGen: true,
|
|
capabilities: {
|
|
provider: "visionary",
|
|
apiFormat: "visionary-task",
|
|
supportedModes,
|
|
supportedAspectRatios: params.supportedAspectRatios,
|
|
supportedImageSizes: params.supportedImageSizes,
|
|
supportsMultiImageReference: true,
|
|
maxReferenceImages: 9,
|
|
supportsQuality: Boolean(params.supportsQuality),
|
|
},
|
|
defaultParams: {
|
|
provider: "visionary",
|
|
apiFormat: "visionary-task",
|
|
endpoint: params.modelId,
|
|
imageSize: params.defaultImageSize,
|
|
aspectRatio: "auto",
|
|
quality: "auto",
|
|
supportedModes,
|
|
},
|
|
imageGenConfig: {
|
|
apiFormat: "visionary-task",
|
|
maxImages: 1,
|
|
supportsSize: true,
|
|
supports1K: params.supportedImageSizes.includes("1K"),
|
|
supports2K: params.supportedImageSizes.includes("2K"),
|
|
supports4K: params.supportedImageSizes.includes("4K"),
|
|
supportsPromptExtend: Boolean(params.supportsPromptExtend),
|
|
supportsNegativePrompt: false,
|
|
supportsWatermark: false,
|
|
supportsSeed: false,
|
|
supportsQuality: Boolean(params.supportsQuality),
|
|
maxReferenceImages: 9,
|
|
supportedImageSizes: params.supportedImageSizes,
|
|
supportedAspectRatios: params.supportedAspectRatios,
|
|
enableLoadingPlaceholder: true,
|
|
loadingColor: "yellow",
|
|
},
|
|
sortOrder: params.sortOrder,
|
|
} satisfies VisionaryModelPreset;
|
|
}
|
|
|
|
export const VISIONARY_MODEL_PRESETS: VisionaryModelPreset[] = [
|
|
buildVisionaryPreset({
|
|
modelId: "gpt-image-2",
|
|
displayName: "Visionary GPT Image 2",
|
|
description:
|
|
"Visionary GPT Image 2。支持文生图、最多 9 张参考图、完整比例选择、质量档位和 1K/2K/4K 输出。",
|
|
supportedAspectRatios: VISIONARY_GPT_IMAGE_RATIOS,
|
|
supportedImageSizes: ["1K", "2K", "4K"],
|
|
defaultImageSize: "1K",
|
|
supportsQuality: true,
|
|
sortOrder: 10,
|
|
}),
|
|
buildVisionaryPreset({
|
|
modelId: "nano-banana-pro",
|
|
displayName: "Visionary Nano Banana Pro",
|
|
description:
|
|
"Visionary Nano Banana Pro。支持文生图、多图编辑、中文文字增强、极端比例和 2K/4K 输出。",
|
|
supportedAspectRatios: VISIONARY_NANO_BANANA_RATIOS,
|
|
supportedImageSizes: ["2K", "4K"],
|
|
defaultImageSize: "2K",
|
|
supportsPromptExtend: true,
|
|
sortOrder: 20,
|
|
}),
|
|
buildVisionaryPreset({
|
|
modelId: "nano-banana-pro-cl",
|
|
displayName: "Visionary Nano Banana Pro CL",
|
|
description:
|
|
"Visionary Nano Banana Pro CL 开放 API 高质量线路。支持文生图、多图编辑、极端比例和 2K/4K 输出。",
|
|
supportedAspectRatios: VISIONARY_NANO_BANANA_RATIOS,
|
|
supportedImageSizes: ["2K", "4K"],
|
|
defaultImageSize: "2K",
|
|
sortOrder: 30,
|
|
}),
|
|
buildVisionaryPreset({
|
|
modelId: "nano-banana-2-lite",
|
|
displayName: "Visionary Nano Banana 2 Lite",
|
|
description:
|
|
"Visionary Nano Banana 2 Lite 低延迟线路。支持文生图、多图编辑和极端比例,固定输出 1K。",
|
|
supportedAspectRatios: VISIONARY_NANO_BANANA_RATIOS,
|
|
supportedImageSizes: ["1K"],
|
|
defaultImageSize: "1K",
|
|
sortOrder: 40,
|
|
}),
|
|
];
|
|
|
|
export function getVisionaryModelPresetById(modelId: string) {
|
|
return VISIONARY_MODEL_PRESETS.find(
|
|
(preset) => preset.modelId === String(modelId || "").trim()
|
|
);
|
|
}
|