image strugles 2
This commit is contained in:
@@ -10,6 +10,42 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Fields already added via direct SQL, just mark as noop
|
||||
# This ensures the model matches the database schema
|
||||
# Declare the fields in Django schema so migrations can use them
|
||||
# These fields already exist in DB, so state_operations syncs Django's understanding
|
||||
migrations.SeparateDatabaseAndState(
|
||||
state_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'])",
|
||||
),
|
||||
),
|
||||
],
|
||||
database_operations=[
|
||||
# No DB operations - fields already exist via direct SQL
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# Generated manually - Add Seedream 4.5 image model and update quality_tier choices
|
||||
from decimal import Decimal
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def add_seedream_model(apps, schema_editor):
|
||||
"""
|
||||
Add ByteDance Seedream 4.5 image model via Runware.
|
||||
|
||||
Model specs:
|
||||
- model: bytedance:seedream@4.5
|
||||
- Square size: 2048x2048
|
||||
- Landscape size: 2304x1728
|
||||
- Quality tier: quality_option2
|
||||
- Credits per image: 5
|
||||
"""
|
||||
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
|
||||
|
||||
AIModelConfig.objects.update_or_create(
|
||||
model_name='bytedance:seedream@4.5',
|
||||
defaults={
|
||||
'display_name': 'Seedream 4.5 - High Quality',
|
||||
'model_type': 'image',
|
||||
'provider': 'runware',
|
||||
'is_default': False,
|
||||
'is_active': True,
|
||||
'credits_per_image': 5,
|
||||
'quality_tier': 'quality_option2',
|
||||
'landscape_size': '2304x1728',
|
||||
'square_size': '2048x2048',
|
||||
'valid_sizes': ['2048x2048', '2304x1728', '2560x1440', '1728x2304', '1440x2560'],
|
||||
'capabilities': {
|
||||
'max_sequential_images': 4,
|
||||
'high_resolution': True,
|
||||
'provider_settings': {
|
||||
'bytedance': {
|
||||
'maxSequentialImages': 4
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
print("✅ Added Seedream 4.5 image model")
|
||||
|
||||
|
||||
def reverse_migration(apps, schema_editor):
|
||||
"""Remove Seedream model"""
|
||||
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
|
||||
AIModelConfig.objects.filter(model_name='bytedance:seedream@4.5').delete()
|
||||
print("❌ Removed Seedream 4.5 image model")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
"""Add Seedream 4.5 image model and update quality_tier choices."""
|
||||
|
||||
dependencies = [
|
||||
('billing', '0030_add_aimodel_image_sizes'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Update quality_tier field choices to include quality_option2
|
||||
migrations.AlterField(
|
||||
model_name='aimodelconfig',
|
||||
name='quality_tier',
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
choices=[
|
||||
('basic', 'Basic'),
|
||||
('quality', 'Quality'),
|
||||
('quality_option2', 'Quality-Option2'),
|
||||
('premium', 'Premium'),
|
||||
],
|
||||
help_text='basic / quality / quality_option2 / premium - for image models',
|
||||
max_length=20,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
# Add the Seedream model
|
||||
migrations.RunPython(add_seedream_model, reverse_migration),
|
||||
]
|
||||
@@ -50,6 +50,7 @@ class SystemAISettings(models.Model):
|
||||
QUALITY_TIER_CHOICES = [
|
||||
('basic', 'Basic'),
|
||||
('quality', 'Quality'),
|
||||
('quality_option2', 'Quality-Option2'),
|
||||
('premium', 'Premium'),
|
||||
]
|
||||
|
||||
@@ -191,6 +192,30 @@ class SystemAISettings(models.Model):
|
||||
return str(override)
|
||||
return cls.get_instance().image_size
|
||||
|
||||
@classmethod
|
||||
def get_effective_quality_tier(cls, account=None) -> str:
|
||||
"""Get quality_tier, checking account override first (from ai_settings key)"""
|
||||
if account:
|
||||
# Check consolidated ai_settings first
|
||||
try:
|
||||
from igny8_core.modules.system.settings_models import AccountSettings
|
||||
setting = AccountSettings.objects.filter(
|
||||
account=account,
|
||||
key='ai_settings'
|
||||
).first()
|
||||
if setting and setting.value:
|
||||
tier = setting.value.get('quality_tier')
|
||||
if tier:
|
||||
return str(tier)
|
||||
except Exception as e:
|
||||
logger.debug(f"Could not get quality_tier from ai_settings: {e}")
|
||||
|
||||
# Fall back to individual key
|
||||
override = cls._get_account_override(account, 'ai.quality_tier')
|
||||
if override is not None:
|
||||
return str(override)
|
||||
return cls.get_instance().default_quality_tier
|
||||
|
||||
@staticmethod
|
||||
def _get_account_override(account, key: str):
|
||||
"""Get account-specific override from AccountSettings"""
|
||||
|
||||
@@ -594,10 +594,12 @@ class ContentGenerationSettingsViewSet(viewsets.ViewSet):
|
||||
tier = model.quality_tier or 'basic'
|
||||
# Avoid duplicates
|
||||
if not any(t['tier'] == tier for t in quality_tiers):
|
||||
# Format label: quality_option2 -> "Quality-Option2"
|
||||
tier_label = tier.replace('_', '-').title() if tier else 'Basic'
|
||||
quality_tiers.append({
|
||||
'tier': tier,
|
||||
'credits': model.credits_per_image or 1,
|
||||
'label': tier.title(),
|
||||
'label': tier_label,
|
||||
'description': f"{model.display_name} quality",
|
||||
'model': model.model_name,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user