New Model & tokens/credits updates
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
"""
|
||||
Management command to seed initial AI model configurations
|
||||
"""
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import transaction
|
||||
from igny8_core.business.billing.models import AIModelConfig
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Seeds initial AI model configurations with pricing data'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write('Seeding AI model configurations...')
|
||||
|
||||
models_data = [
|
||||
{
|
||||
'model_name': 'gpt-4o-mini',
|
||||
'provider': 'openai',
|
||||
'model_type': 'text',
|
||||
'cost_per_1k_input_tokens': 0.000150, # $0.15 per 1M tokens
|
||||
'cost_per_1k_output_tokens': 0.000600, # $0.60 per 1M tokens
|
||||
'tokens_per_credit': 50, # 50 tokens = 1 credit (more expensive)
|
||||
'display_name': 'GPT-4o Mini',
|
||||
'is_active': True,
|
||||
'is_default': True, # Set as default text model
|
||||
},
|
||||
{
|
||||
'model_name': 'gpt-4-turbo-2024-04-09',
|
||||
'provider': 'openai',
|
||||
'model_type': 'text',
|
||||
'cost_per_1k_input_tokens': 0.010000, # $10 per 1M tokens
|
||||
'cost_per_1k_output_tokens': 0.030000, # $30 per 1M tokens
|
||||
'tokens_per_credit': 30, # 30 tokens = 1 credit (premium)
|
||||
'display_name': 'GPT-4 Turbo',
|
||||
'is_active': True,
|
||||
'is_default': False,
|
||||
},
|
||||
{
|
||||
'model_name': 'gpt-3.5-turbo',
|
||||
'provider': 'openai',
|
||||
'model_type': 'text',
|
||||
'cost_per_1k_input_tokens': 0.000500, # $0.50 per 1M tokens
|
||||
'cost_per_1k_output_tokens': 0.001500, # $1.50 per 1M tokens
|
||||
'tokens_per_credit': 200, # 200 tokens = 1 credit (cheaper)
|
||||
'display_name': 'GPT-3.5 Turbo',
|
||||
'is_active': True,
|
||||
'is_default': False,
|
||||
},
|
||||
{
|
||||
'model_name': 'claude-3-5-sonnet-20241022',
|
||||
'provider': 'anthropic',
|
||||
'model_type': 'text',
|
||||
'cost_per_1k_input_tokens': 0.003000, # $3 per 1M tokens
|
||||
'cost_per_1k_output_tokens': 0.015000, # $15 per 1M tokens
|
||||
'tokens_per_credit': 40, # 40 tokens = 1 credit
|
||||
'display_name': 'Claude 3.5 Sonnet',
|
||||
'is_active': True,
|
||||
'is_default': False,
|
||||
},
|
||||
{
|
||||
'model_name': 'claude-3-haiku-20240307',
|
||||
'provider': 'anthropic',
|
||||
'model_type': 'text',
|
||||
'cost_per_1k_input_tokens': 0.000250, # $0.25 per 1M tokens
|
||||
'cost_per_1k_output_tokens': 0.001250, # $1.25 per 1M tokens
|
||||
'tokens_per_credit': 150, # 150 tokens = 1 credit (budget)
|
||||
'display_name': 'Claude 3 Haiku',
|
||||
'is_active': True,
|
||||
'is_default': False,
|
||||
},
|
||||
{
|
||||
'model_name': 'runware-flux-1.1-pro',
|
||||
'provider': 'runware',
|
||||
'model_type': 'image',
|
||||
'cost_per_1k_input_tokens': 0.000000, # Image models don't use input tokens
|
||||
'cost_per_1k_output_tokens': 0.040000, # $0.04 per image (treat as "tokens")
|
||||
'tokens_per_credit': 1, # 1 "token" (image) = 1 credit
|
||||
'display_name': 'Runware FLUX 1.1 Pro',
|
||||
'is_active': True,
|
||||
'is_default': True, # Set as default image model
|
||||
},
|
||||
{
|
||||
'model_name': 'dall-e-3',
|
||||
'provider': 'openai',
|
||||
'model_type': 'image',
|
||||
'cost_per_1k_input_tokens': 0.000000,
|
||||
'cost_per_1k_output_tokens': 0.040000, # $0.040 per standard image
|
||||
'tokens_per_credit': 1,
|
||||
'display_name': 'DALL-E 3',
|
||||
'is_active': True,
|
||||
'is_default': False,
|
||||
},
|
||||
]
|
||||
|
||||
created_count = 0
|
||||
updated_count = 0
|
||||
|
||||
with transaction.atomic():
|
||||
for data in models_data:
|
||||
model, created = AIModelConfig.objects.update_or_create(
|
||||
model_name=data['model_name'],
|
||||
defaults=data
|
||||
)
|
||||
|
||||
if created:
|
||||
created_count += 1
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f'✓ Created: {model.display_name}')
|
||||
)
|
||||
else:
|
||||
updated_count += 1
|
||||
self.stdout.write(
|
||||
self.style.WARNING(f'↻ Updated: {model.display_name}')
|
||||
)
|
||||
|
||||
self.stdout.write('\n' + '='*60)
|
||||
self.stdout.write(self.style.SUCCESS(
|
||||
f'✓ Successfully processed {len(models_data)} AI models'
|
||||
))
|
||||
self.stdout.write(f' - Created: {created_count}')
|
||||
self.stdout.write(f' - Updated: {updated_count}')
|
||||
self.stdout.write('='*60)
|
||||
Reference in New Issue
Block a user