Image genartiona dn temaplte design redesign
This commit is contained in:
@@ -800,6 +800,11 @@ class AIModelConfigAdmin(SimpleHistoryAdmin, Igny8ModelAdmin):
|
||||
'description': 'For IMAGE models only',
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
('Image Model Sizes', {
|
||||
'fields': ('landscape_size', 'square_size', 'valid_sizes'),
|
||||
'description': 'For IMAGE models: specify supported image dimensions',
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
('Capabilities', {
|
||||
'fields': ('capabilities',),
|
||||
'description': 'JSON: vision, function_calling, json_mode, etc.',
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
# Generated migration for adding image size fields to AIModelConfig
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def populate_image_sizes(apps, schema_editor):
|
||||
"""Populate image sizes based on model name"""
|
||||
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
|
||||
|
||||
# Model-specific sizes
|
||||
model_sizes = {
|
||||
'runware:97@1': {
|
||||
'landscape_size': '1280x768',
|
||||
'square_size': '1024x1024',
|
||||
'valid_sizes': ['1024x1024', '1280x768', '768x1280'],
|
||||
},
|
||||
'bria:10@1': {
|
||||
'landscape_size': '1344x768',
|
||||
'square_size': '1024x1024',
|
||||
'valid_sizes': ['1024x1024', '1344x768', '768x1344'],
|
||||
},
|
||||
'google:4@2': {
|
||||
'landscape_size': '1376x768',
|
||||
'square_size': '1024x1024',
|
||||
'valid_sizes': ['1024x1024', '1376x768', '768x1376'],
|
||||
},
|
||||
'dall-e-3': {
|
||||
'landscape_size': '1792x1024',
|
||||
'square_size': '1024x1024',
|
||||
'valid_sizes': ['1024x1024', '1792x1024', '1024x1792'],
|
||||
},
|
||||
'dall-e-2': {
|
||||
'landscape_size': '1024x1024',
|
||||
'square_size': '1024x1024',
|
||||
'valid_sizes': ['256x256', '512x512', '1024x1024'],
|
||||
},
|
||||
}
|
||||
|
||||
for model_name, sizes in model_sizes.items():
|
||||
AIModelConfig.objects.filter(
|
||||
model_name=model_name,
|
||||
model_type='image'
|
||||
).update(**sizes)
|
||||
|
||||
|
||||
def reverse_migration(apps, schema_editor):
|
||||
"""Clear image size fields"""
|
||||
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
|
||||
AIModelConfig.objects.filter(model_type='image').update(
|
||||
landscape_size=None,
|
||||
square_size='1024x1024',
|
||||
valid_sizes=[],
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0026_populate_aimodel_credits'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='aimodelconfig',
|
||||
name='landscape_size',
|
||||
field=models.CharField(blank=True, help_text="Landscape image size for this model (e.g., '1792x1024', '1280x768')", max_length=20, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='aimodelconfig',
|
||||
name='square_size',
|
||||
field=models.CharField(blank=True, default='1024x1024', help_text="Square image size for this model (e.g., '1024x1024')", max_length=20),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='aimodelconfig',
|
||||
name='valid_sizes',
|
||||
field=models.JSONField(blank=True, default=list, help_text="List of valid sizes for this model (e.g., ['1024x1024', '1792x1024'])"),
|
||||
),
|
||||
migrations.RunPython(populate_image_sizes, reverse_migration),
|
||||
]
|
||||
Reference in New Issue
Block a user