Files
igny8/docs/plans/4th-jan-refactor/simple-ai-models-credits-image-gen.md
IGNY8 VPS (Salman) 6e30d2d4e8 Django admin cleanup
2026-01-04 06:04:37 +00:00

91 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
My Recommendation: Simplify to 3 Core Concepts
Based on analyzing your plans and the current system, here's the simplest path forward:
Current Pain Points (Summarized)
Area Problem
API Keys Scattered in GlobalIntegrationSettings with unused fields (anthropic, bria)
Models Duplicated in DB (AIModelConfig), constants.py, GlobalIntegrationSettings CHOICES, frontend
Credits Split between CreditCostConfig (token-based) and image models (per-image) - confusing
Frontend Hardcoded model lists, not dynamic
Proposed Simplified Architecture
Instead of 7-phase migration, do this:
┌─────────────────────────────────────────────────────────────────┐
│ SIMPLIFIED TARGET STATE │
└─────────────────────────────────────────────────────────────────┘
1. AIModelConfig (ENHANCED) - SINGLE SOURCE OF TRUTH
├── All models (text + image)
├── is_default flag (one per type)
├── tokens_per_credit (text models)
├── credits_per_image (image models)
├── quality_tier (basic/quality/premium for user display)
└── provider field links to API key source
2. IntegrationProvider (NEW) - API KEYS ONLY
├── openai → api_key
├── runware → api_key
└── (future: resend, stripe, etc.)
3. GlobalIntegrationSettings (SIMPLIFIED) - NON-MODEL SETTINGS ONLY
├── image_style: "photorealistic"
├── max_in_article_images: 4
└── temperature: 0.7
(NO model names, NO API keys, NO hardcoded choices)
User-Facing Simplification
For Images (what user sees):
Quality Selection:
○ Basic (1 credit/image) ← maps to runware:97@1
○ Quality (5 credits/image) ← maps to dall-e-3
○ Premium (15 credits/image) ← maps to google:4@2
Image Count: [1-8 dropdown]
User picks quality tier + count. Backend handles:
Model selection based on quality_tier
Credit calculation: credits_per_image × count
API routing to correct provider
For Text (hidden from user):
Admin controls default model in AIModelConfig.is_default
User has NO options - uses system default
Credits calculated: ceil(tokens / tokens_per_credit)
Simplest Migration Path
Phase 1: Add fields to AIModelConfig (no breaking changes)
# Add to existing AIModelConfig
credits_per_image = IntegerField(null=True) # For image models
tokens_per_credit = IntegerField(null=True) # For text models
quality_tier = CharField(choices=['basic','quality','premium'])
Phase 2: Create IntegrationProvider (move API keys)
# New simple model
class IntegrationProvider(Model):
provider_id = CharField(primary_key=True) # openai, runware
api_key = CharField()
is_active = BooleanField()
Phase 3: Create single API endpoint
GET /api/v1/system/ai-config/
Returns:
{
"image_qualities": [
{"tier": "basic", "credits_per_image": 1, "label": "Basic"},
{"tier": "quality", "credits_per_image": 5, "label": "Quality"},
{"tier": "premium", "credits_per_image": 15, "label": "Premium"}
],
"text_model": "gpt-5.1", // Admin-controlled, user can't change
"image_style": "photorealistic",
"max_images": 4
}
Phase 4: Update frontend - load from API, remove hardcodes Phase 5: Cleanup - remove legacy fields from GlobalIntegrationSettings
Key Simplifications
Before After
User picks model name User picks quality tier
Multiple credit calculation paths One path: AIModelConfig
API keys in GlobalIntegrationSettings API keys in IntegrationProvider
Hardcoded constants.py rates All from database
6+ admin pages to configure 2 pages: Models + Providers
Do you want me to:
Start implementing this simplified approach? - I can create the migration files and update the models
Create a more detailed breakdown of each phase with specific file changes?
Focus on a specific area first (e.g., just fix image credits, or just move API keys)?
The existing plans in your docs are comprehensive but may be over-engineered. The core problem is simpler: consolidate to AIModelConfig as single source of truth, give users quality tiers instead of model names, and move API keys to a dedicated model.