Skip to content

Commit eec66bc

Browse files
genz27warp-agent
andcommitted
feat: add model ID mapping preset for Gemini Pro resolutions
Co-Authored-By: Warp <agent@warp.dev>
1 parent 48e10f4 commit eec66bc

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

app/admin/image-channels/page.tsx

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ const DEFAULT_RATIO_ROWS: RatioResolutionRow[] = [
4242
{ ratio: '9:16', resolution: '1024x1792' },
4343
];
4444

45-
// Gemini 3 Pro standard resolutions
46-
const GEMINI_PRO_SIZE_GROUPS: SizeResolutionGroup[] = [
45+
// Gemini 3 Pro standard resolutions (pixel values for display)
46+
const GEMINI_PRO_SIZE_GROUPS_PIXELS: SizeResolutionGroup[] = [
4747
{
4848
size: '1K',
4949
rows: [
@@ -91,6 +91,32 @@ const GEMINI_PRO_SIZE_GROUPS: SizeResolutionGroup[] = [
9191
},
9292
];
9393

94+
// Gemini 3 Pro model ID mapping (for dynamic model selection)
95+
// Format: gemini-3.0-pro-image-{ratio}[-{size}]
96+
const buildGeminiProModelGroups = (baseModel: string): SizeResolutionGroup[] => {
97+
// Extract base name, e.g. "gemini-3.0-pro-image" from "gemini-3.0-pro-image-square"
98+
const baseName = baseModel.replace(/-(landscape|portrait|square|four-three|three-four)(-2k|-4k)?$/i, '');
99+
100+
const ratioToSuffix: Record<string, string> = {
101+
'1:1': 'square',
102+
'16:9': 'landscape',
103+
'9:16': 'portrait',
104+
'4:3': 'four-three',
105+
'3:4': 'three-four',
106+
};
107+
108+
const sizes = ['1K', '2K', '4K'];
109+
const sizeSuffixes: Record<string, string> = { '1K': '', '2K': '-2k', '4K': '-4k' };
110+
111+
return sizes.map(size => ({
112+
size,
113+
rows: Object.entries(ratioToSuffix).map(([ratio, suffix]) => ({
114+
ratio,
115+
resolution: `${baseName}-${suffix}${sizeSuffixes[size]}`,
116+
})),
117+
}));
118+
};
119+
94120
export default function ImageChannelsPage() {
95121
const [channels, setChannels] = useState<ImageChannel[]>([]);
96122
const [models, setModels] = useState<ImageModel[]>([]);
@@ -940,10 +966,19 @@ export default function ImageChannelsPage() {
940966
<div className="flex items-center gap-3">
941967
<button
942968
type="button"
943-
onClick={() => setSizeGroups([...GEMINI_PRO_SIZE_GROUPS])}
969+
onClick={() => setSizeGroups(buildGeminiProModelGroups(modelForm.apiModel))}
944970
className="text-xs text-blue-400 hover:text-blue-300"
971+
title="根据模型ID自动生成对应的模型ID映射,如 gemini-3.0-pro-image-square-2k"
972+
>
973+
填充模型ID映射
974+
</button>
975+
<button
976+
type="button"
977+
onClick={() => setSizeGroups([...GEMINI_PRO_SIZE_GROUPS_PIXELS])}
978+
className="text-xs text-foreground/60 hover:text-foreground"
979+
title="填充像素分辨率值,仅用于显示"
945980
>
946-
填充 Gemini Pro 默认
981+
填充像素值
947982
</button>
948983
<button
949984
type="button"

0 commit comments

Comments
 (0)