refactor: Fix AI billing system - revert to commit #10 + fixes

- Reverted to commit #10 (98e68f6) for stable AI function base
- Fixed database migrations: removed 0018-0019 that broke schema
- Fixed CreditCostConfig schema: restored credits_cost, unit fields
- Fixed historical table schema for django-simple-history
- Added debug system (staged for future use)

Changes:
- CreditCostConfig: Updated OPERATION_TYPE_CHOICES (10 ops, no duplicates)
- CreditUsageLog: Updated choices with legacy aliases marked
- Migration 0018_update_operation_choices: Applied successfully
- All AI operations working (clustering, ideas, content, optimization, etc.)

Test Results:
✓ CreditCostConfig save/load working
✓ Credit check passing for all operations
✓ AICore initialization successful
✓ AIEngine operation mapping functional
✓ Admin panel accessible without 500 errors

Future: AI-MODEL-COST-REFACTOR-PLAN.md created for token-based system
This commit is contained in:
IGNY8 VPS (Salman)
2025-12-23 05:21:52 +00:00
parent 98e68f6bd8
commit 1d4825ad77
14 changed files with 1279 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
"""
Management command to test debug logging system
"""
from django.core.management.base import BaseCommand
from igny8_core.utils.debug import is_debug_enabled, debug_log, debug_log_ai_step
class Command(BaseCommand):
help = 'Test debug logging system'
def handle(self, *args, **options):
self.stdout.write("=== Testing Debug System ===\n")
# Check if debug is enabled
enabled = is_debug_enabled()
self.stdout.write(f"Debug enabled: {enabled}\n")
if enabled:
self.stdout.write("Debug is ENABLED - logs should appear below:\n")
# Test general debug log
debug_log("Test message 1 - General category", category='general')
# Test AI step log
debug_log_ai_step("TEST_STEP", "Test AI step message", test_param="value123", count=42)
# Test different categories
debug_log("Test message 2 - AI steps", category='ai_steps')
debug_log("Test message 3 - API requests", category='api_requests')
self.stdout.write("\n✓ Test logs sent (check console output above)\n")
else:
self.stdout.write("Debug is DISABLED - no logs should appear\n")
# Try to log anyway (should be skipped)
debug_log("This should NOT appear", category='general')
debug_log_ai_step("SKIP", "This should also NOT appear")
self.stdout.write("✓ Logs were correctly skipped\n")
self.stdout.write("\n=== Test Complete ===\n")