IMage genartion service and models revamp - #Migration Runs
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
"""
|
||||
Migration: Update Runware/Image model configurations for new model structure
|
||||
|
||||
This migration:
|
||||
1. Updates runware:97@1 to "Hi Dream Full - Basic"
|
||||
2. Adds Bria 3.2 model as bria:10@1 (correct AIR ID)
|
||||
3. Adds Nano Banana (Google) as google:4@2 (Premium tier)
|
||||
4. Removes old civitai model reference
|
||||
5. Adds one_liner_description field values
|
||||
"""
|
||||
from decimal import Decimal
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def update_image_models(apps, schema_editor):
|
||||
"""Update image models in AIModelConfig"""
|
||||
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
|
||||
|
||||
# Update existing runware:97@1 model
|
||||
AIModelConfig.objects.update_or_create(
|
||||
model_name='runware:97@1',
|
||||
defaults={
|
||||
'display_name': 'Hi Dream Full - Basic',
|
||||
'model_type': 'image',
|
||||
'provider': 'runware',
|
||||
'cost_per_image': Decimal('0.006'), # Basic tier, cheaper
|
||||
'valid_sizes': ['1024x1024', '1280x768', '768x1280'],
|
||||
'supports_json_mode': False,
|
||||
'supports_vision': False,
|
||||
'supports_function_calling': False,
|
||||
'is_active': True,
|
||||
'is_default': True,
|
||||
'sort_order': 10,
|
||||
'description': 'Fast & affordable image generation. Steps: 20, CFG: 7. Good for quick iterations.',
|
||||
}
|
||||
)
|
||||
|
||||
# Add Bria 3.2 model with correct AIR ID
|
||||
AIModelConfig.objects.update_or_create(
|
||||
model_name='bria:10@1',
|
||||
defaults={
|
||||
'display_name': 'Bria 3.2 - Quality',
|
||||
'model_type': 'image',
|
||||
'provider': 'runware', # Via Runware API
|
||||
'cost_per_image': Decimal('0.010'), # Quality tier
|
||||
'valid_sizes': ['1024x1024', '1344x768', '768x1344', '1216x832', '832x1216'],
|
||||
'supports_json_mode': False,
|
||||
'supports_vision': False,
|
||||
'supports_function_calling': False,
|
||||
'is_active': True,
|
||||
'is_default': False,
|
||||
'sort_order': 11,
|
||||
'description': 'Commercial-safe AI. Steps: 8, prompt enhancement enabled. Licensed training data.',
|
||||
}
|
||||
)
|
||||
|
||||
# Add Nano Banana (Google) Premium model
|
||||
AIModelConfig.objects.update_or_create(
|
||||
model_name='google:4@2',
|
||||
defaults={
|
||||
'display_name': 'Nano Banana - Premium',
|
||||
'model_type': 'image',
|
||||
'provider': 'runware', # Via Runware API
|
||||
'cost_per_image': Decimal('0.015'), # Premium tier
|
||||
'valid_sizes': ['1024x1024', '1376x768', '768x1376', '1264x848', '848x1264'],
|
||||
'supports_json_mode': False,
|
||||
'supports_vision': False,
|
||||
'supports_function_calling': False,
|
||||
'is_active': True,
|
||||
'is_default': False,
|
||||
'sort_order': 12,
|
||||
'description': 'Google Gemini 3 Pro. Best quality, text rendering, advanced reasoning. Premium pricing.',
|
||||
}
|
||||
)
|
||||
|
||||
# Deactivate old civitai model (replaced by correct bria:10@1)
|
||||
AIModelConfig.objects.filter(
|
||||
model_name='civitai:618692@691639'
|
||||
).update(is_active=False)
|
||||
|
||||
# Deactivate other old models
|
||||
AIModelConfig.objects.filter(
|
||||
model_name__in=['runware:100@1', 'runware:101@1']
|
||||
).update(is_active=False)
|
||||
|
||||
|
||||
def reverse_migration(apps, schema_editor):
|
||||
"""Reverse the migration"""
|
||||
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
|
||||
|
||||
# Restore old display names
|
||||
AIModelConfig.objects.filter(model_name='runware:97@1').update(
|
||||
display_name='Hi Dream Full - Standard',
|
||||
)
|
||||
|
||||
# Remove new models
|
||||
AIModelConfig.objects.filter(model_name__in=['bria:10@1', 'google:4@2']).delete()
|
||||
|
||||
# Re-activate old models
|
||||
AIModelConfig.objects.filter(
|
||||
model_name__in=['runware:100@1', 'runware:101@1', 'civitai:618692@691639']
|
||||
).update(is_active=True)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0023_update_runware_models'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(update_image_models, reverse_migration),
|
||||
]
|
||||
Reference in New Issue
Block a user