From 5b1b53ff3a4ef92386c9ac185451718f4467125c Mon Sep 17 00:00:00 2001 From: root Date: Sun, 29 Jun 2025 14:18:20 +0200 Subject: [PATCH] Fix exploratory questions: implement proper conversational responses - Modified backend to return conversationalResponse for exploratory questions instead of parsing into steps - Updated displayAIGuidance to handle new response format - Added displayConversationalResponse method for proper conversation interface - Fixed 'offline guidance' fallback issue for exploratory questions - Updated cache-busting parameter to force browser refresh --- html/kidsai/index.html | 5 ++++- html/kidsai/script.js | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/html/kidsai/index.html b/html/kidsai/index.html index 9a9d98e..071bcf9 100755 --- a/html/kidsai/index.html +++ b/html/kidsai/index.html @@ -1,5 +1,8 @@ - + + + + ang="en"> diff --git a/html/kidsai/script.js b/html/kidsai/script.js index 563f603..5af2ed3 100644 --- a/html/kidsai/script.js +++ b/html/kidsai/script.js @@ -184,6 +184,14 @@ class KidsAIExplorer { `; this.thinkingSteps.appendChild(encouragementDiv); + // Handle exploratory questions with conversational response + if (guidance.questionType === 'exploratory' && guidance.conversationalResponse) { + setTimeout(() => { + this.displayConversationalResponse(guidance.conversationalResponse); + }, 500); + return; + } + // Handle exploratory questions with conversational response if (guidance.questionType === 'exploratory' && guidance.conversationalResponse) { // Create conversational interface directly @@ -287,6 +295,44 @@ class KidsAIExplorer { }, 500); } + displayConversationalResponse(aiResponse) { + // Create conversation interface + const conversationDiv = document.createElement('div'); + conversationDiv.className = 'ai-conversation'; + + // Check if AI response contains a question + const hasQuestion = aiResponse.includes('?'); + + conversationDiv.innerHTML = ` +
+
🤖
+
${aiResponse}
+
+ + AI Teacher +
+
+ ${hasQuestion ? ` +
+
+ + +
+
+ ` : ''} + `; + + this.thinkingSteps.appendChild(conversationDiv); + + // Set up conversation interaction if there's a question + if (hasQuestion) { + this.setupAIConversation(conversationDiv); + } + } + addCompletionMessage(questionType) { const completionSection = document.createElement('div'); completionSection.className = 'completion-message';