Auto commit: 2025-11-18T10:48:24.787Z
This commit is contained in:
parent
7dc21c2972
commit
78612e6972
37
api/chat.php
37
api/chat.php
@ -44,34 +44,19 @@ if ($_SESSION['question_index'] < count($questions)) {
|
|||||||
foreach ($_SESSION['answers'] as $index => $answer) {
|
foreach ($_SESSION['answers'] as $index => $answer) {
|
||||||
$formatted_answers[] = "Q: " . $questions[$index] . "\nA: " . $answer;
|
$formatted_answers[] = "Q: " . $questions[$index] . "\nA: " . $answer;
|
||||||
}
|
}
|
||||||
$prompt = "You are a burnout analysis expert. A user has completed a burnout survey. The user answered on a scale of 1-5 where 1 is 'Never' and 5 is 'Always'. Analyze the following survey answers and provide a detailed analysis. Return the response as a JSON object with the following structure:
|
$prompt = <<<'EOD'
|
||||||
{
|
You are a burnout analysis expert. A user has completed a burnout survey. The user answered on a scale of 1-5 where 1 is 'Never' and 5 is 'Always'. Analyze the following survey answers and provide a detailed analysis.
|
||||||
\"scores\": {
|
|
||||||
\"Exhaustion\": <score_0_to_5>,
|
Return the response as a JSON object. The JSON object must have the following keys: "scores", "analysis", "recommendations", and "nextSteps".
|
||||||
\"Cynicism\": <score_0_to_5>,
|
|
||||||
\"Inefficacy\": <score_0_to_5>
|
- "scores" should be an object with keys "Exhaustion", "Cynicism", and "Inefficacy", each with a numeric score from 0 to 5.
|
||||||
},
|
- "analysis" should be an object with keys "overallSummary", "exhaustionSummary", "cynicismSummary", and "inefficacySummary", each containing a string with the corresponding analysis.
|
||||||
\"analysis\": {
|
- "recommendations" should be an array of objects, where each object has a "title" and a "description".
|
||||||
\"overallSummary\": \"<A paragraph summarizing the user's burnout level and key areas of concern.>\",
|
- "nextSteps" should be an array of strings.
|
||||||
\"exhaustionSummary\": \"<A sentence or two explaining the exhaustion score.>\",
|
|
||||||
\"cynicismSummary\": \"<A sentence or two explaining the cynicism score.>\",
|
|
||||||
\"inefficacySummary\": \"<A sentence or two explaining the inefficacy score.>\"
|
|
||||||
},
|
|
||||||
\"recommendations\": [
|
|
||||||
{
|
|
||||||
\"title\": \"<Short recommendation title>\",
|
|
||||||
\"description\": \"<Longer description of the recommendation, explaining why it's important and how to implement it.>\"
|
|
||||||
},
|
|
||||||
... (provide 3 to 5 detailed recommendations)
|
|
||||||
],
|
|
||||||
\"nextSteps\": [
|
|
||||||
\"<A suggestion for a next step, e.g., 'Consider talking to a mental health professional.'>\",
|
|
||||||
\"<Another suggestion, e.g., 'Explore mindfulness exercises.'>\"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
Answers:
|
Answers:
|
||||||
" . implode("\n\n", $formatted_answers);
|
EOD;
|
||||||
|
$prompt .= implode("\n\n", $formatted_answers);
|
||||||
|
|
||||||
$ai_response = LocalAIApi::createResponse([
|
$ai_response = LocalAIApi::createResponse([
|
||||||
'input' => [
|
'input' => [
|
||||||
|
|||||||
BIN
assets/pasted-20251118-104529-37f09ec1.png
Normal file
BIN
assets/pasted-20251118-104529-37f09ec1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 190 KiB |
Loading…
x
Reference in New Issue
Block a user