🔍 Quick System Status Check"; echo ""; try { // Test 1: Check configuration echo "

1. Configuration Check

"; if (defined('COST_EFFECTIVE_MODE') && COST_EFFECTIVE_MODE) { echo "
✅ Cost-effective mode is active
"; echo "
📊 Using model: " . GPT_MODEL . "
"; echo "
📊 Max tokens: " . GPT_MAX_TOKENS . "
"; echo "
📊 Requests per minute: " . GPT_REQUESTS_PER_MINUTE . "
"; if (defined('MAX_DAILY_COST')) { echo "
💰 Daily cost limit: $" . MAX_DAILY_COST . "
"; } } else { echo "
âš ī¸ Cost-effective mode not detected - make sure you uploaded the updated config.php
"; } // Test 2: Database connection echo "

2. Database Connection

"; $db = Database::getInstance(); echo "
✅ Database connected successfully
"; // Test 3: Check OptimAIze status echo "

3. OptimAIze Status

"; $totalResult = $db->query("SELECT COUNT(*) as total FROM panel_directives"); $totalDirectives = $totalResult->fetch_assoc()['total']; $checkedResult = $db->query("SELECT COUNT(*) as checked FROM panel_directives WHERE llm_checked = 1"); $checkedDirectives = $checkedResult->fetch_assoc()['checked']; $uncheckedResult = $db->query("SELECT COUNT(*) as unchecked FROM panel_directives WHERE llm_checked = 0"); $uncheckedDirectives = $uncheckedResult->fetch_assoc()['unchecked']; echo "
📊 Total combinations: " . number_format($totalDirectives) . "
"; echo "
✅ Already processed: " . number_format($checkedDirectives) . " (" . round(($checkedDirectives/$totalDirectives)*100, 1) . "%)
"; echo "
âŗ Remaining: " . number_format($uncheckedDirectives) . " (" . round(($uncheckedDirectives/$totalDirectives)*100, 1) . "%)
"; // Test 4: Cost estimation echo "

4. Cost Estimation with New Settings

"; $avgTokensPerRequest = defined('AVERAGE_TOKENS_PER_REQUEST') ? AVERAGE_TOKENS_PER_REQUEST : 200; $costPer1kTokens = defined('GPT35_COST_PER_1K_TOKENS') ? GPT35_COST_PER_1K_TOKENS : 0.002; $estimatedCostRemaining = ($uncheckedDirectives * $avgTokensPerRequest * $costPer1kTokens) / 1000; echo "
💰 Model: " . GPT_MODEL . "
"; echo "
💰 Cost per 1K tokens: $" . number_format($costPer1kTokens, 4) . "
"; echo "
💰 Estimated cost to complete: $" . number_format($estimatedCostRemaining, 2) . "
"; // Compare with GPT-4 cost $gpt4Cost = ($uncheckedDirectives * $avgTokensPerRequest * 0.03) / 1000; $savings = $gpt4Cost - $estimatedCostRemaining; echo "
🎉 Cost savings vs GPT-4: $" . number_format($savings, 2) . " (" . round((1 - $estimatedCostRemaining/$gpt4Cost)*100, 1) . "% cheaper!)
"; // Test 5: Cache status echo "

5. Cache System

"; $cacheStats = GptHelper::getCacheStats(); echo "
📊 Cache statistics:
"; echo "
" . json_encode($cacheStats, JSON_PRETTY_PRINT) . "
"; if ($cacheStats['total_cached'] > 0) { echo "
✅ Cache is working - {$cacheStats['total_cached']} combinations cached
"; echo "
💰 Estimated savings from cache: $" . number_format($cacheStats['cost_saved_by_cache'], 2) . "
"; } else { echo "
â„šī¸ No cached combinations yet - cache will build as processing runs
"; } // Test 6: API Test echo "

6. OpenAI API Test

"; echo "
🔍 Testing API connection with new settings...
"; try { $result = GptHelper::analyzeCombination('Age', '5 years', 'Education', 'PhD'); echo "
✅ API test successful!
"; echo "
📊 Result: " . ($result['is_impossible'] ? 'IMPOSSIBLE' : 'POSSIBLE') . "
"; echo "
💡 Reasoning: " . htmlspecialchars($result['reasoning']) . "
"; if (isset($result['daily_cost'])) { echo "
💰 Daily cost so far: $" . number_format($result['daily_cost'], 4) . "
"; } if (isset($result['model_used'])) { echo "
🤖 Model used: " . $result['model_used'] . "
"; } if (isset($result['cached']) && $result['cached']) { echo "
⚡ Result was cached - no API cost!
"; } } catch (Exception $e) { echo "
❌ API test failed: " . htmlspecialchars($e->getMessage()) . "
"; if (strpos($e->getMessage(), 'quota') !== false || strpos($e->getMessage(), 'billing') !== false) { echo "
🚨 This is still a billing/quota issue. You need to add credits to your OpenAI account.
"; echo "
👉 Go to: OpenAI Billing Dashboard
"; } } // Test 7: Rate limit status echo "

7. Rate Limit Status

"; $rateLimitStatus = GptHelper::getRateLimitStatus(true); echo "
📊 Rate limit status:
"; echo "
" . json_encode($rateLimitStatus, JSON_PRETTY_PRINT) . "
"; } catch (Exception $e) { echo "
❌ System check failed: " . htmlspecialchars($e->getMessage()) . "
"; } echo "

📋 What to Do Next

"; echo "
"; echo "

If API test was successful:

"; echo "
    "; echo "
  1. Start small test: Process 10-20 combinations first
  2. "; echo "
  3. Monitor costs: Check the daily cost tracking
  4. "; echo "
  5. Scale up gradually: Increase batch sizes if all goes well
  6. "; echo "
  7. Use your OptimAIze page: The enhanced system should work much better now
  8. "; echo "
"; echo "
"; echo "
"; echo "

If API test failed:

"; echo "
    "; echo "
  1. Fix OpenAI billing: Add credits to your account
  2. "; echo "
  3. Check account status: Make sure it's active
  4. "; echo "
  5. Wait 10-15 minutes: After adding credits, then test again
  6. "; echo "
  7. Contact me: If issues persist, let me know the exact error
  8. "; echo "
"; echo "
"; echo "
"; echo "

✅ System Improvements Applied:

"; echo ""; echo "
"; ?>