Stage 3 & stage 4

This commit is contained in:
Desktop
2025-11-10 23:51:59 +05:00
parent 1bd9ebc974
commit 14beeed75c
7 changed files with 72 additions and 2259 deletions

View File

@@ -15,33 +15,15 @@ from django.core.cache import cache
logger = logging.getLogger(__name__)
# Model pricing (per 1M tokens) - EXACT from reference plugin model-rates-config.php
MODEL_RATES = {
'gpt-4.1': {'input': 2.00, 'output': 8.00},
'gpt-4o-mini': {'input': 0.15, 'output': 0.60},
'gpt-4o': {'input': 2.50, 'output': 10.00},
}
# Image model pricing (per image) - EXACT from reference plugin
IMAGE_MODEL_RATES = {
'dall-e-3': 0.040,
'dall-e-2': 0.020,
'gpt-image-1': 0.042,
'gpt-image-1-mini': 0.011,
}
# Valid OpenAI image generation models (only these work with /v1/images/generations endpoint)
VALID_OPENAI_IMAGE_MODELS = {
'dall-e-3',
'dall-e-2',
# Note: gpt-image-1 and gpt-image-1-mini are NOT valid for OpenAI's /v1/images/generations endpoint
}
# Valid image sizes per model (from OpenAI official documentation)
VALID_SIZES_BY_MODEL = {
'dall-e-3': ['1024x1024', '1024x1792', '1792x1024'],
'dall-e-2': ['256x256', '512x512', '1024x1024'],
}
# Import constants from unified location
from igny8_core.ai.constants import (
MODEL_RATES,
IMAGE_MODEL_RATES,
VALID_OPENAI_IMAGE_MODELS,
VALID_SIZES_BY_MODEL,
DEFAULT_AI_MODEL,
JSON_MODE_MODELS,
)
class AIProcessor: