+
Analyze Your CSV Data with AI
+
Upload your CSV file, and our AI will provide a description of the dataset and suggest relevant charts.
+
+
+
+ [
+ ['role' => 'system', 'content' => 'You are a data analysis expert.'],
+ ['role' => 'user', 'content' => $prompt],
+ ],
+ ]);
+
+ if (!empty($resp['success'])) {
+ $ai_text = LocalAIApi::extractText($resp);
+ // Use nl2br to preserve line breaks from the AI response
+ $analysis_result = "
Analysis for ".htmlspecialchars($file_name)."
" . nl2br(htmlspecialchars($ai_text)) . "
";
+ } else {
+ $error_message = $resp['error'] ?? 'An unknown error occurred with the AI API.';
+ $analysis_result = "
Error during AI analysis: " . htmlspecialchars($error_message) . "
";
+ }
+ } else {
+ $analysis_result = "
Could not read data from the CSV file.
";
+ }
+ } else {
+ $analysis_result = "
Error uploading file.
";
+ }
+ echo $analysis_result;
+ }
+ ?>
+
+
+