Analyze Your Data
Upload a CSV file to get started. Our AI will analyze the data and suggest the best visualizations for your dataset.
';
echo '';
echo '
';
}
// Display Data Preview
if ($header) {
echo 'AI Analysis
';
if (!empty($resp['success'])) {
$aiReply = LocalAIApi::extractText($resp);
if (!empty($aiReply)) {
// Simple markdown to HTML
$formattedReply = nl2br(htmlspecialchars($aiReply));
$formattedReply = preg_replace('/\*\*([^*]+)\*\*/', '$1', $formattedReply);
$formattedReply = preg_replace('/\*([^*]+)\*/', '$1', $formattedReply);
$formattedReply = preg_replace('/`([^`]+)`/', '
';
echo '$1', $formattedReply);
echo '' . $formattedReply . '
';
} else {
echo 'AI analysis could not be displayed. The AI returned an empty or invalid response.
';
}
} else {
$error = $resp['error'] ?? 'An unknown error occurred.';
echo 'Could not retrieve AI analysis. Error: ' . htmlspecialchars($error) . '
';
}
echo '';
echo '';
echo '
';
}
} else {
echo 'Data Preview
';
echo '
';
echo '';
echo '
';
echo '
| ' . htmlspecialchars($col) . ' | '; } echo '
|---|
| ' . htmlspecialchars($cell) . ' | '; } echo '
Please select a valid CSV file.
';
}
}
?>