Analyzing your responses...
` or `
` tags.\n2. `chart_data`: A JSON object with two keys: `labels` (an array of strings for the chart categories, e.g., ['Exhaustion', 'Cynicism', 'Inefficacy']) and `scores` (an array of integers from 0 to 10 representing the user's score in each category).\n\nHere is the conversation: "; foreach ($conversation as $item) { $prompt .= "Q: " . $item['question'] . "\nA: " . $item['answer'] . "\n\n"; } $resp = LocalAIApi::createResponse( [ 'input' => [ ['role' => 'system', 'content' => 'You are a helpful assistant specializing in mental health and burnout analysis. You always respond with a valid JSON object.'], ['role' => 'user', 'content' => $prompt], ], ] ); if (!empty($resp['success'])) { $ai_response_raw = LocalAIApi::extractText($resp); $ai_response_data = json_decode($ai_response_raw, true); if ($ai_response_data && isset($ai_response_data['analysis_html']) && isset($ai_response_data['chart_data'])) { $ai_response_text = $ai_response_data['analysis_html']; $chart_data_json = json_encode($ai_response_data['chart_data']); } else { $error_message = 'AI response was not in the expected format. Please try again.'; // For debugging: $error_message .= "