query("SELECT id, attribute1_name, choice1, attribute2_name, choice2 FROM panel_directives WHERE llm_checked = 0 LIMIT 5"); if (!$query || $query->num_rows === 0) { echo json_encode([ 'success' => true, 'has_more' => false, 'processed' => 0, 'progress' => ['total' => 0, 'processed' => 0, 'remaining' => 0, 'percentage' => 100], 'message' => 'All combinations processed' ]); exit; } $processed = 0; $results = []; // Process all combinations in this batch while ($combo = $query->fetch_assoc()) { // Process the combination $result = GptHelper::analyzeCombination( $combo['attribute1_name'], $combo['choice1'], $combo['attribute2_name'], $combo['choice2'] ); if ($result['success']) { $isImpossible = $result['is_impossible'] ? 1 : 0; $reasoning = $result['reasoning']; // Update database $updateStmt = $db->prepare("UPDATE panel_directives SET llm_checked = 1, is_impossible = ?, llm_reasoning = ? WHERE id = ?"); $updateStmt->bind_param('isi', $isImpossible, $reasoning, $combo['id']); $updateStmt->execute(); $processed++; $results[] = [ 'combination' => "{$combo['attribute1_name']}={$combo['choice1']} + {$combo['attribute2_name']}={$combo['choice2']}", 'result' => $isImpossible ? 'IMPOSSIBLE' : 'POSSIBLE' ]; } else { // If one fails, return error echo json_encode([ 'success' => false, 'has_more' => true, 'error' => $result['error'], 'progress' => ['total' => 0, 'processed' => 0, 'remaining' => 0, 'percentage' => 0] ]); exit; } } // Get updated counts $totalQuery = $db->query("SELECT COUNT(*) as total FROM panel_directives"); $total = $totalQuery->fetch_assoc()['total']; $processedQuery = $db->query("SELECT COUNT(*) as processed FROM panel_directives WHERE llm_checked = 1"); $totalProcessed = $processedQuery->fetch_assoc()['processed']; $hasMore = $totalProcessed < $total; $percentage = $total > 0 ? ($totalProcessed / $total) * 100 : 100; echo json_encode([ 'success' => true, 'has_more' => $hasMore, 'processed' => $processed, 'progress' => [ 'total' => (int)$total, 'processed' => (int)$totalProcessed, 'remaining' => (int)($total - $totalProcessed), 'percentage' => round($percentage, 1) ], 'results' => $results, 'batch_size' => $processed ]); } catch (Exception $e) { echo json_encode([ 'success' => false, 'has_more' => false, 'error' => $e->getMessage(), 'progress' => ['total' => 0, 'processed' => 0, 'remaining' => 0, 'percentage' => 0] ]); } exit; } // BROWSER MODE - HTML output ?> OptimAIze Processor

OptimAIze Processor

✅ All files loaded successfully"; $db = Database::getInstance(); echo "
✅ Database connected
"; // Check pending combinations $pendingQuery = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 0"); $pending = $pendingQuery->fetch_assoc()['count']; $processedQuery = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 1"); $processed = $processedQuery->fetch_assoc()['count']; echo "
📊 Pending: " . number_format($pending) . " | Processed: " . number_format($processed) . "
"; if ($pending == 0) { echo "
🎉 All combinations have been processed!
"; echo "

View OptimAIze Dashboard | Back to Main Site

"; } else { if (isset($_GET['process'])) { echo "

🔄 Processing Combinations...

"; $batchSize = 5; $query = $db->query("SELECT id, attribute1_name, choice1, attribute2_name, choice2 FROM panel_directives WHERE llm_checked = 0 LIMIT $batchSize"); $count = 0; while ($combo = $query->fetch_assoc()) { $count++; echo "
[$count] Processing: {$combo['attribute1_name']}={$combo['choice1']} + {$combo['attribute2_name']}={$combo['choice2']}
"; flush(); $result = GptHelper::analyzeCombination( $combo['attribute1_name'], $combo['choice1'], $combo['attribute2_name'], $combo['choice2'] ); if ($result['success']) { $isImpossible = $result['is_impossible'] ? 1 : 0; $reasoning = $result['reasoning']; $updateStmt = $db->prepare("UPDATE panel_directives SET llm_checked = 1, is_impossible = ?, llm_reasoning = ? WHERE id = ?"); $updateStmt->bind_param('isi', $isImpossible, $reasoning, $combo['id']); $updateStmt->execute(); echo "
✅ " . ($isImpossible ? 'IMPOSSIBLE' : 'POSSIBLE') . " - " . substr($reasoning, 0, 60) . "...
"; } else { echo "
❌ Error: " . htmlspecialchars($result['error']) . "
"; break; } flush(); // Removed sleep(1) for faster processing } echo "
✅ Batch of $count combinations completed!
"; echo "

🔄 Process Another Batch

"; } else { echo "

🚀 Ready to Process

"; echo "

▶️ Start Processing (Batch of 5)

"; echo "

Note: This will process 5 combinations at a time. Click multiple times to process all.

"; } } } catch (Exception $e) { echo "
❌ Error: " . htmlspecialchars($e->getMessage()) . "
"; echo "

Check your configuration and try again.

"; } ?>

📊 View OptimAIze Dashboard | 🏠 Back to Main Site