đ 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 "";
}
}
// 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 "- Start small test: Process 10-20 combinations first
";
echo "- Monitor costs: Check the daily cost tracking
";
echo "- Scale up gradually: Increase batch sizes if all goes well
";
echo "- Use your OptimAIze page: The enhanced system should work much better now
";
echo "
";
echo "
";
echo "";
echo "
If API test failed:
";
echo "
";
echo "- Fix OpenAI billing: Add credits to your account
";
echo "- Check account status: Make sure it's active
";
echo "- Wait 10-15 minutes: After adding credits, then test again
";
echo "- Contact me: If issues persist, let me know the exact error
";
echo "
";
echo "
";
echo "";
echo "
â
System Improvements Applied:
";
echo "
";
echo "- đ¤ Using GPT-3.5-turbo (90% cheaper than GPT-4)
";
echo "- đ° Daily cost limits to prevent overspending
";
echo "- đī¸ Intelligent caching to reduce API calls
";
echo "- ⥠Better rate limiting and error recovery
";
echo "- đ Real-time cost tracking
";
echo "
";
echo "
";
?>