Repository navigation
Expand file tree
/
Copy pathmodel-config.ts
More file actions
400 lines (387 loc) · 10.6 KB
/
Copy pathmodel-config.ts
File metadata and controls
400 lines (387 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// ========================================
// 模型配置 - 图像生成和视频生成
// ========================================
// 图像生成模型配置
export interface ImageModelConfig {
id: string;
name: string;
description: string;
provider: 'gemini' | 'zimage' | 'sora';
channel?: 'modelscope' | 'gitee'; // zimage 专用
apiModel: string; // 实际调用的模型名称
highlight?: boolean;
requiresReferenceImage?: boolean;
allowEmptyPrompt?: boolean;
features: {
supportReferenceImage: boolean; // 是否支持参考图
supportImageSize: boolean; // 是否支持分辨率选择 (1K/2K/4K)
supportMultipleImages?: boolean; // 是否支持多张参考图
};
aspectRatios: string[]; // 支持的画面比例
resolutions: Record<string, string | Record<string, string>>; // 比例对应的分辨率
imageSizes?: string[]; // 支持的分辨率档位 (Pro 专用)
defaultAspectRatio: string;
defaultImageSize?: string;
}
// 视频生成模型配置
export interface VideoModelConfig {
id: string;
name: string;
description: string;
provider: 'sora';
apiModel: string;
features: {
supportReferenceFile: boolean; // 是否支持参考素材
};
aspectRatios: { value: string; label: string; icon: string }[];
durations: { value: string; label: string }[];
defaultAspectRatio: string;
defaultDuration: string;
}
// ========================================
// 图像生成模型配置
// ========================================
export const IMAGE_MODELS: ImageModelConfig[] = [
// Sora Image (优先显示)
{
id: 'sora-image',
name: 'Sora Image',
description: '高质量图像',
provider: 'sora',
apiModel: 'sora-image',
features: {
supportReferenceImage: true,
supportImageSize: false,
},
aspectRatios: ['1:1', '3:2', '2:3'],
resolutions: {
'1:1': '1024x1024',
'3:2': '1792x1024',
'2:3': '1024x1792',
},
defaultAspectRatio: '1:1',
},
// Gemini Nano (Flash)
{
id: 'gemini-nano',
name: 'Gemini Nano',
description: '极速生成',
provider: 'gemini',
apiModel: 'gemini-2.5-flash-image',
features: {
supportReferenceImage: true,
supportImageSize: false,
supportMultipleImages: true,
},
aspectRatios: ['1:1', '2:3', '3:2', '3:4', '4:3', '4:5', '5:4', '9:16', '16:9', '21:9'],
resolutions: {
'1:1': '1024x1024',
'2:3': '832x1248',
'3:2': '1248x832',
'3:4': '864x1184',
'4:3': '1184x864',
'4:5': '896x1152',
'5:4': '1152x896',
'9:16': '768x1344',
'16:9': '1344x768',
'21:9': '1536x672',
},
defaultAspectRatio: '1:1',
},
// Gemini Pro
{
id: 'gemini-pro',
name: 'Gemini Pro',
description: '4K 高清',
provider: 'gemini',
apiModel: 'gemini-3-pro-image-preview',
features: {
supportReferenceImage: true,
supportImageSize: true,
supportMultipleImages: true,
},
aspectRatios: ['1:1', '2:3', '3:2', '3:4', '4:3', '4:5', '5:4', '9:16', '16:9', '21:9'],
imageSizes: ['1K', '2K', '4K'],
resolutions: {
'1K': {
'1:1': '1024x1024',
'2:3': '848x1264',
'3:2': '1264x848',
'3:4': '896x1200',
'4:3': '1200x896',
'4:5': '928x1152',
'5:4': '1152x928',
'9:16': '768x1376',
'16:9': '1376x768',
'21:9': '1584x672',
},
'2K': {
'1:1': '2048x2048',
'2:3': '1696x2528',
'3:2': '2528x1696',
'3:4': '1792x2400',
'4:3': '2400x1792',
'4:5': '1856x2304',
'5:4': '2304x1856',
'9:16': '1536x2752',
'16:9': '2752x1536',
'21:9': '3168x1344',
},
'4K': {
'1:1': '4096x4096',
'2:3': '3392x5056',
'3:2': '5056x3392',
'3:4': '3584x4800',
'4:3': '4800x3584',
'4:5': '3712x4608',
'5:4': '4608x3712',
'9:16': '3072x5504',
'16:9': '5504x3072',
'21:9': '6336x2688',
},
},
defaultAspectRatio: '1:1',
defaultImageSize: '1K',
},
// Z-Image Gitee
{
id: 'zimage-gitee',
name: 'Z-Image Gitee',
description: '2K 高清',
provider: 'zimage',
channel: 'gitee',
apiModel: 'z-image-turbo',
features: {
supportReferenceImage: false,
supportImageSize: false,
},
aspectRatios: ['1:1', '4:3', '3:4', '3:2', '2:3', '16:9', '9:16'],
resolutions: {
'1:1': '2048x2048',
'4:3': '2048x1536',
'3:4': '1536x2048',
'3:2': '2048x1360',
'2:3': '1360x2048',
'16:9': '2048x1152',
'9:16': '1152x2048',
},
defaultAspectRatio: '1:1',
},
// Z-Image ModelScope
{
id: 'zimage-modelscope',
name: 'Z-Image ModelScope',
description: '1K 标准',
provider: 'zimage',
channel: 'modelscope',<
109AF
/div>
apiModel: 'Tongyi-MAI/Z-Image-Turbo',
features: {
supportReferenceImage: false,
supportImageSize: false,
},
aspectRatios: ['1:1', '1:2', '4:3', '3:4', '16:9', '9:16'],
resolutions: {
'1:1': '1024x1024',
'1:2': '720x1440',
'4:3': '1152x864',
'3:4': '864x1152',
'16:9': '1280x720',
'9:16': '720x1280',
},
defaultAspectRatio: '1:1',
},
// Qwen Image
{
id: 'qwen-image',
name: 'Qwen Image',
description: 'ModelScope 文生图',
provider: 'zimage',
channel: 'modelscope',
apiModel: 'Qwen/Qwen-Image',
features: {
supportReferenceImage: false,
supportImageSize: false,
},
aspectRatios: ['1:1', '1:2', '4:3', '3:4', '16:9', '9:16'],
resolutions: {
'1:1': '1024x1024',
'1:2': '720x1440',
'4:3': '1152x864',
'3:4': '864x1152',
'16:9': '1280x720',
'9:16': '720x1280',
},
defaultAspectRatio: '1:1',
},
// Qwen Image Edit
{
id: 'qwen-image-edit',
name: 'Qwen Image Edit',
description: 'ModelScope 图像编辑',
provider: 'zimage',
channel: 'modelscope',
apiModel: 'Qwen/Qwen-Image-Edit-2509',
requiresReferenceImage: true,
features: {
supportReferenceImage: true,
supportImageSize: false,
},
aspectRatios: ['1:1', '1:2', '4:3', '3:4', '16:9', '9:16'],
resolutions: {
'1:1': '1024x1024',
'1:2': '720x1440',
'4:3': '1152x864',
'3:4': '864x1152',
'16:9': '1280x720',
'9:16': '720x1280',
},
defaultAspectRatio: '1:1',
},
// FLUX.2 Dev
{
id: 'flux-2-dev',
name: 'FLUX.2 Dev',
description: 'ModelScope 图生图',
provider: 'zimage',
channel: 'modelscope',
apiModel: 'black-forest-labs/FLUX.2-dev',
features: {
supportReferenceImage: true,
supportImageSize: false,
},
aspectRatios: ['1:1', '1:2', '4:3', '3:4', '16:9', '9:16'],
resolutions: {
'1:1': '1024x1024',
'1:2': '720x1440',
'4:3': '1152x864',
'3:4': '864x1152',
'16:9': '1280x720',
'9:16': '720x1280',
},
defaultAspectRatio: '1:1',
},
// RMBG Matting (Gitee)
{
id: 'rmbg-2',
name: 'RMBG 2.0',
description: 'Gitee AI 抠图',
provider: 'zimage',
channel: 'gitee',
apiModel: 'RMBG-2.0',
requiresReferenceImage: true,
allowEmptyPrompt: true,
features: {
supportReferenceImage: true,
supportImageSize: false,
},
aspectRatios: ['原图'],
resolutions: {
原图: '',
},
defaultAspectRatio: '原图',
},
// SeedVR2 Upscale (Gitee)
{
id: 'seedvr2-upscale',
name: 'SeedVR2 HD',
description: 'Gitee AI 超清修复 · <=5MB, <=1440px',
provider: 'zimage',
channel: 'gitee',
apiModel: 'SeedVR2-3B',
highlight: true,
requiresReferenceImage: true,
allowEmptyPrompt: true,
features: {
supportReferenceImage: true,
supportImageSize: false,
},
aspectRatios: ['原图'],
resolutions: {
原图: '',
},
defaultAspectRatio: '原图',
},
];
// ========================================
// 视频生成模型配置
// ========================================
export const VIDEO_MODELS: VideoModelConfig[] = [
{
id: 'sora',
name: 'Sora',
description: 'OpenAI 视频生成',
provider: 'sora',
apiModel: 'sora-video',
features: {
supportReferenceFile: true,
},
aspectRatios: [
{ value: 'landscape', label: '16:9', icon: '▬' },
{ value: 'portrait', label: '9:16', icon: '▮' },
],
durations: [
{ value: '8s', label: '8 秒' },
],
defaultAspectRatio: 'landscape',
defaultDuration: '8s',
},
];
// ========================================
// 辅助函数
// ========================================
export function getImageModelById(id: string): ImageModelConfig | undefined {
return IMAGE_MODELS.find((m) => m.id === id);
}
export function getVideoModelById(id: string): VideoModelConfig | undefined {
return VIDEO_MODELS.find((m) => m.id === id);
}
// 根据渠道启用状态过滤图像模型
export function filterImageModelsByChannel(
models: ImageModelConfig[],
channelEnabled: { sora: boolean; gemini: boolean; zimage: boolean; gitee: boolean },
disabledModels: string[] = []
): ImageModelConfig[] {
return models.filter((model) => {
// 先检查是否被单独禁用
if (disabledModels.includes(model.id)) return false;
// 再检查渠道是否启用
if (model.provider === 'sora') return channelEnabled.sora;
if (model.provider === 'gemini') return channelEnabled.gemini;
if (model.provider === 'zimage') {
if (model.channel === 'gitee') return channelEnabled.gitee;
return channelEnabled.zimage;
}
return true;
});
}
// 根据渠道启用状态过滤视频模型
export function filterVideoModelsByChannel(
models: VideoModelConfig[],
channelEnabled: { sora: boolean; gemini: boolean; zimage: boolean; gitee: boolean },
disabledModels: string[] = []
): VideoModelConfig[] {
return models.filter((model) => {
// 先检查是否被单独禁用
if (disabledModels.includes(model.id)) return false;
// 再检查渠道是否启用
if (model.provider === 'sora') return channelEnabled.sora;
return true;
});
}
// 获取图像模型的当前分辨率
export function getImageResolution(
model: ImageModelConfig,
aspectRatio: string,
imageSize?: string
): string {
if (model.features.supportImageSize && imageSize && typeof model.resolutions[imageSize] === 'object') {
return (model.resolutions[imageSize] as Record<string, string>)[aspectRatio] || '';
}
return (model.resolutions as Record<string, string>)[aspectRatio] || '';
}
// 构建 Sora 模型 ID
// 新格式: sora2-{orientation}-{duration}
// 例如: sora2-landscape-8s, sora2-portrait-8s
export function buildSoraModelId(ratio: string, duration: string): string {
return `sora2-${ratio}-${duration}`;
}