Auto commit: 2025-11-18T11:08:58.699Z

This commit is contained in:
Flatlogic Bot 2025-11-18 11:08:58 +00:00
parent 3317cb7a89
commit 86776affbc
3 changed files with 18 additions and 31 deletions

View File

@ -45,30 +45,7 @@ if ($_SESSION['question_index'] < count($questions)) {
$formatted_answers[] = "Q: " . $questions[$index] . "\nA: " . $answer;
}
$prompt = <<<EOT
You are a burnout analysis expert. A user has answered a survey on a 1-5 scale (1='Never', 5='Always').
Analyze their answers and return ONLY a raw JSON object with the following structure:
{
"scores": {
"Exhaustion": <number>,
"Cynicism": <number>,
"Inefficacy": <number>
},
"analysis": {
"overallSummary": "<string>",
"exhaustionSummary": "<string>",
"cynicismSummary": "<string>",
"inefficacySummary": "<string>"
},
"recommendations": [
{
"title": "<string>",
"description": "<string>"
}
],
"nextSteps": [
"<string>"
]
}
Analyze the user's survey answers and return ONLY a raw JSON object with the specified structure. Do not include any other text or formatting.
User's Answers:
EOT;

View File

@ -2,6 +2,8 @@ document.addEventListener('DOMContentLoaded', function () {
const chatWindow = document.getElementById('chat-window');
const chatInput = document.getElementById('chat-input');
const sendBtn = document.getElementById('send-btn');
const progressContainer = document.getElementById('progress-container');
const inputContainer = document.getElementById('input-container');
function addMessage(message, sender) {
const messageElement = document.createElement('div');
@ -50,17 +52,22 @@ document.addEventListener('DOMContentLoaded', function () {
const data = await getNextQuestion(rating);
if (data.redirect) {
window.location.href = data.redirect;
inputContainer.style.display = 'none';
progressContainer.style.display = 'block';
// Wait a bit for the user to see the progress bar
setTimeout(() => {
window.location.href = data.redirect;
}, 2000);
} else if (data.question) {
addMessage(data.question, 'bot');
chatInput.disabled = false;
sendBtn.disabled = false;
chatInput.focus();
} else if (data.message) {
addMessage(data.message, 'bot');
chatInput.style.display = 'none';
sendBtn.style.display = 'none';
}
chatInput.disabled = false;
sendBtn.disabled = false;
chatInput.focus();
}
sendBtn.addEventListener('click', handleUserInput);
@ -79,4 +86,4 @@ document.addEventListener('DOMContentLoaded', function () {
}
startConversation();
});
});

View File

@ -25,8 +25,11 @@ if (session_status() == PHP_SESSION_NONE) {
<div class="card-body" id="chat-window" style="height: 400px; overflow-y: auto;">
<!-- Chat messages will be appended here -->
</div>
<div class="card-footer">
<div class="input-group">
<div class="card-footer">
<div id="progress-container" class="progress" style="display: none;">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 100%">Analyzing...</div>
</div>
<div class="input-group" id="input-container">
<input type="text" id="chat-input" class="form-control" placeholder="Rate from 1 (Strongly Disagree) to 5 (Strongly Agree)">
<button id="send-btn" class="btn btn-primary">
<i class="bi bi-send"></i>