| |
| |
| |
| |
|
|
| export interface ModelConfig { |
| |
| internalModel: string; |
| |
| draftVersion: string; |
| |
| features: { |
| |
| multiImage: boolean; |
| |
| imageToImage: boolean; |
| |
| videoGeneration: boolean; |
| }; |
| |
| defaultParams: { |
| |
| width: number; |
| |
| height: number; |
| |
| resolutions: Array<{ width: number; height: number }>; |
| |
| sampleStrengthRange: [number, number]; |
| }; |
| |
| specialConfig?: { |
| |
| specialHeaders?: Record<string, string>; |
| |
| extraParams?: Record<string, any>; |
| }; |
| } |
|
|
| |
| export const MODEL_CONFIGS: Record<string, ModelConfig> = { |
| "jimeng-5.0-preview": { |
| internalModel: "high_aes_general_v50", |
| draftVersion: "3.3.9", |
| features: { |
| multiImage: true, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 2048, |
| height: 2048, |
| resolutions: [ |
| { width: 1024, height: 1024 }, |
| { width: 768, height: 1024 }, |
| { width: 1024, height: 768 }, |
| { width: 1024, height: 576 }, |
| { width: 576, height: 1024 }, |
| { width: 1024, height: 682 }, |
| { width: 682, height: 1024 }, |
| { width: 1195, height: 512 }, |
| { width: 2048, height: 2048 }, |
| { width: 2304, height: 1728 }, |
| { width: 1728, height: 2304 }, |
| { width: 2560, height: 1440 }, |
| { width: 1440, height: 2560 }, |
| { width: 2496, height: 1664 }, |
| { width: 1664, height: 2496 }, |
| { width: 3024, height: 1296 }, |
| ], |
| sampleStrengthRange: [0.1, 1.0], |
| }, |
| }, |
| "jimeng-4.6": { |
| internalModel: "high_aes_general_v42", |
| draftVersion: "3.3.9", |
| features: { |
| multiImage: true, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 2048, |
| height: 2048, |
| resolutions: [ |
| { width: 1024, height: 1024 }, |
| { width: 768, height: 1024 }, |
| { width: 1024, height: 768 }, |
| { width: 1024, height: 576 }, |
| { width: 576, height: 1024 }, |
| { width: 1024, height: 682 }, |
| { width: 682, height: 1024 }, |
| { width: 1195, height: 512 }, |
| { width: 2048, height: 2048 }, |
| { width: 2304, height: 1728 }, |
| { width: 1728, height: 2304 }, |
| { width: 2560, height: 1440 }, |
| { width: 1440, height: 2560 }, |
| { width: 2496, height: 1664 }, |
| { width: 1664, height: 2496 }, |
| { width: 3024, height: 1296 }, |
| ], |
| sampleStrengthRange: [0.1, 1.0], |
| }, |
| }, |
| "jimeng-video-3.5-pro": { |
| internalModel: "dreamina_ic_generate_video_model_vgfm_3.5_pro", |
| draftVersion: "3.3.4", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: true, |
| }, |
| defaultParams: { |
| width: 1280, |
| height: 720, |
| resolutions: [ |
| { width: 1280, height: 720 }, |
| { width: 720, height: 1280 }, |
| { width: 1080, height: 1080 }, |
| { width: 1920, height: 1080 }, |
| { width: 1080, height: 1920 }, |
| ], |
| sampleStrengthRange: [0.1, 1.0], |
| }, |
| }, |
| "jimeng-4.5": { |
| internalModel: "high_aes_general_v40l", |
| draftVersion: "3.3.4", |
| features: { |
| multiImage: true, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 2048, |
| height: 2048, |
| resolutions: [ |
| { width: 1024, height: 1024 }, |
| { width: 768, height: 1024 }, |
| { width: 1024, height: 768 }, |
| { width: 1024, height: 576 }, |
| { width: 576, height: 1024 }, |
| { width: 1024, height: 682 }, |
| { width: 682, height: 1024 }, |
| { width: 1195, height: 512 }, |
| { width: 2048, height: 2048 }, |
| { width: 2304, height: 1728 }, |
| { width: 1728, height: 2304 }, |
| { width: 2560, height: 1440 }, |
| { width: 1440, height: 2560 }, |
| { width: 2496, height: 1664 }, |
| { width: 1664, height: 2496 }, |
| { width: 3024, height: 1296 }, |
| ], |
| sampleStrengthRange: [0.1, 1.0], |
| }, |
| }, |
| "jimeng-4.1": { |
| internalModel: "high_aes_general_v41", |
| draftVersion: "3.3.4", |
| features: { |
| multiImage: true, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 2048, |
| height: 2048, |
| resolutions: [ |
| { width: 1024, height: 1024 }, |
| { width: 768, height: 1024 }, |
| { width: 1024, height: 768 }, |
| { width: 1024, height: 576 }, |
| { width: 576, height: 1024 }, |
| { width: 1024, height: 682 }, |
| { width: 682, height: 1024 }, |
| { width: 1195, height: 512 }, |
| { width: 2048, height: 2048 }, |
| { width: 2304, height: 1728 }, |
| { width: 1728, height: 2304 }, |
| { width: 2560, height: 1440 }, |
| { width: 1440, height: 2560 }, |
| { width: 2496, height: 1664 }, |
| { width: 1664, height: 2496 }, |
| { width: 3024, height: 1296 }, |
| ], |
| sampleStrengthRange: [0.1, 1.0], |
| }, |
| }, |
| "jimeng-4.0": { |
| internalModel: "high_aes_general_v40", |
| draftVersion: "3.3.4", |
| features: { |
| multiImage: true, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 2048, |
| height: 2048, |
| resolutions: [ |
| { width: 1024, height: 1024 }, |
| { width: 768, height: 1024 }, |
| { width: 1024, height: 768 }, |
| { width: 1024, height: 576 }, |
| { width: 576, height: 1024 }, |
| { width: 1024, height: 682 }, |
| { width: 682, height: 1024 }, |
| { width: 1195, height: 512 }, |
| { width: 2048, height: 2048 }, |
| { width: 2304, height: 1728 }, |
| { width: 1728, height: 2304 }, |
| { width: 2560, height: 1440 }, |
| { width: 1440, height: 2560 }, |
| { width: 2496, height: 1664 }, |
| { width: 1664, height: 2496 }, |
| { width: 3024, height: 1296 }, |
| ], |
| sampleStrengthRange: [0.1, 1.0], |
| }, |
| }, |
| "jimeng-3.1": { |
| internalModel: "high_aes_general_v30l_art_fangzhou:general_v3.0_18b", |
| draftVersion: "3.0.2", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 1024, |
| height: 1024, |
| resolutions: [ |
| { width: 512, height: 512 }, |
| { width: 768, height: 768 }, |
| { width: 1024, height: 1024 }, |
| ], |
| sampleStrengthRange: [0.1, 0.8], |
| }, |
| }, |
| "jimeng-3.0": { |
| internalModel: "high_aes_general_v30l:general_v3.0_18b", |
| draftVersion: "3.0.2", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 1024, |
| height: 1024, |
| resolutions: [ |
| { width: 512, height: 512 }, |
| { width: 768, height: 768 }, |
| { width: 1024, height: 1024 }, |
| ], |
| sampleStrengthRange: [0.1, 0.8], |
| }, |
| }, |
| "jimeng-2.1": { |
| internalModel: "high_aes_general_v21_L:general_v2.1_L", |
| draftVersion: "3.0.2", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 512, |
| height: 512, |
| resolutions: [ |
| { width: 512, height: 512 }, |
| { width: 768, height: 768 }, |
| ], |
| sampleStrengthRange: [0.1, 0.7], |
| }, |
| }, |
| "jimeng-2.0-pro": { |
| internalModel: "high_aes_general_v20_L:general_v2.0_L", |
| draftVersion: "3.0.2", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 512, |
| height: 512, |
| resolutions: [ |
| { width: 512, height: 512 }, |
| { width: 768, height: 768 }, |
| ], |
| sampleStrengthRange: [0.1, 0.7], |
| }, |
| }, |
| "jimeng-2.0": { |
| internalModel: "high_aes_general_v20", |
| draftVersion: "3.0.2", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 512, |
| height: 512, |
| resolutions: [ |
| { width: 512, height: 512 }, |
| { width: 768, height: 768 }, |
| ], |
| sampleStrengthRange: [0.1, 0.7], |
| }, |
| }, |
| "jimeng-1.4": { |
| internalModel: "high_aes_general_v14:general_v1.4", |
| draftVersion: "3.0.2", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 512, |
| height: 512, |
| resolutions: [ |
| { width: 512, height: 512 }, |
| { width: 768, height: 768 }, |
| ], |
| sampleStrengthRange: [0.1, 0.6], |
| }, |
| }, |
| "jimeng-xl-pro": { |
| internalModel: "text2img_xl_sft", |
| draftVersion: "3.0.2", |
| features: { |
| multiImage: false, |
| imageToImage: true, |
| videoGeneration: false, |
| }, |
| defaultParams: { |
| width: 1024, |
| height: 1024, |
| resolutions: [ |
| { width: 1024, height: 1024 }, |
| { width: 1280, height: 720 }, |
| { width: 720, height: 1280 }, |
| ], |
| sampleStrengthRange: [0.1, 0.8], |
| }, |
| }, |
| }; |
|
|
| |
| export function getModelConfig(modelName: string): ModelConfig { |
| const config = MODEL_CONFIGS[modelName]; |
| if (!config) { |
| throw new Error(`Unsupported model: ${modelName}`); |
| } |
| return config; |
| } |
|
|
| |
| export function getSupportedImageModels(): string[] { |
| return Object.keys(MODEL_CONFIGS); |
| } |
|
|
| |
| export function doesModelSupport(modelName: string, feature: keyof ModelConfig['features']): boolean { |
| const config = getModelConfig(modelName); |
| return config.features[feature]; |
| } |
|
|
| |
| export function validateModelParams(modelName: string, params: { |
| width?: number; |
| height?: number; |
| sampleStrength?: number; |
| }): { isValid: boolean; errors: string[] } { |
| const config = getModelConfig(modelName); |
| const errors: string[] = []; |
|
|
| |
| if (params.width && params.height) { |
| const isValidResolution = config.defaultParams.resolutions.some( |
| res => res.width === params.width && res.height === params.height |
| ); |
| if (!isValidResolution) { |
| errors.push( |
| `Unsupported resolution ${params.width}x${params.height}. Supported resolutions: ${config.defaultParams.resolutions.map(r => `${r.width}x${r.height}`).join(', ')}` |
| ); |
| } |
| } |
|
|
| |
| if (params.sampleStrength !== undefined) { |
| const [min, max] = config.defaultParams.sampleStrengthRange; |
| if (params.sampleStrength < min || params.sampleStrength > max) { |
| errors.push(`Sample strength must be between ${min} and ${max}`); |
| } |
| } |
|
|
| return { |
| isValid: errors.length === 0, |
| errors |
| }; |
| } |