From 589a45e94e826e2992be7cf33a23c9cbef917e6b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 30 Jun 2025 12:54:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=AF=20Fix=20conversational=20flow=20an?= =?UTF-8?q?d=20remove=20redundant=20encouragements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Enhanced 'I don't know' detection to include German variants (ich weiß es nicht, warum, etc.) - When child says 'I don't know', system now directly provides Socratic guidance instead of asking for deeper exploration - Removed redundant phrases like 'Danke, dass du deine Gedanken geteilt hast' for obvious interactions - Improved fallback responses to be more concise and natural ('Perfekt! Lass uns das gemeinsam herausfinden.') - Updated both chat mode and step-by-step mode to have consistent behavior - System now automatically continues to next question for 'don't know' responses, only shows choice buttons for substantial answers This creates a smoother, more natural learning flow without interrupting the Socratic discovery process. --- html/kidsai/script-new.js | 30 ++++++++++++++++++++++-------- html/kidsai/server.js | 15 ++++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/html/kidsai/script-new.js b/html/kidsai/script-new.js index 0b3f58a..8c4bb76 100644 --- a/html/kidsai/script-new.js +++ b/html/kidsai/script-new.js @@ -418,7 +418,11 @@ class KidsAIExplorer { // Analyze the answer to determine the appropriate response type const answerLower = answer.toLowerCase().trim(); const isNegative = answerLower === 'no' || answerLower === 'nein' || answerLower === 'nope' || answerLower === 'nei'; - const isDontKnow = answerLower.includes("don't know") || answerLower.includes('weiß nicht') || answerLower.includes('keine ahnung') || answer.trim().length < 3; + const isDontKnow = answerLower.includes("don't know") || answerLower.includes('weiß nicht') || answerLower.includes('keine ahnung') || + answerLower.includes('ich weiß es nicht') || answerLower.includes('weis es nicht') || answerLower.includes('weiss es nicht') || + answerLower.includes('i dont know') || answerLower.includes("i don't know") || + answerLower === 'warum' || answerLower === 'why' || answerLower === 'warum?' || answerLower === 'why?' || + (answer.trim().length < 5 && (answerLower.includes('weiß') || answerLower.includes('know'))); let response; @@ -427,8 +431,8 @@ class KidsAIExplorer { console.log('📤 Sending guidance request to /api/ask for Socratic questioning'); const guidancePrompt = this.currentLanguage === 'de' - ? `Ein Kind hat "${answer}" geantwortet auf die Frage "${currentQuestion}". Führe es durch Socratic Fragen zur Entdeckung, ohne direkte Antworten zu geben.` - : `A child answered "${answer}" to the question "${currentQuestion}". Guide them through Socratic questions to discovery without giving direct answers.`; + ? `Ein Kind hat "${answer}" geantwortet auf die Frage "${currentQuestion}". Das Kind weiß die Antwort nicht. Führe es durch 2-3 aufbauende Socratic Fragen zur Entdeckung, ohne direkte Antworten zu geben. Beginne mit einfachen Beobachtungen, die das Kind kennt.` + : `A child answered "${answer}" to the question "${currentQuestion}". The child doesn't know the answer. Guide them through 2-3 building Socratic questions to discovery without giving direct answers. Start with simple observations the child would know.`; response = await fetch('/api/ask', { method: 'POST', @@ -557,7 +561,11 @@ class KidsAIExplorer { // Analyze the answer to determine the appropriate response type const answerLower = answer.toLowerCase().trim(); const isNegative = answerLower === 'no' || answerLower === 'nein' || answerLower === 'nope' || answerLower === 'nei'; - const isDontKnow = answerLower.includes("don't know") || answerLower.includes('weiß nicht') || answerLower.includes('keine ahnung') || answer.trim().length < 3; + const isDontKnow = answerLower.includes("don't know") || answerLower.includes('weiß nicht') || answerLower.includes('keine ahnung') || + answerLower.includes('ich weiß es nicht') || answerLower.includes('weis es nicht') || answerLower.includes('weiss es nicht') || + answerLower.includes('i dont know') || answerLower.includes("i don't know") || + answerLower === 'warum' || answerLower === 'why' || answerLower === 'warum?' || answerLower === 'why?' || + (answer.trim().length < 5 && (answerLower.includes('weiß') || answerLower.includes('know'))); let response; @@ -566,8 +574,8 @@ class KidsAIExplorer { console.log('📤 Sending guidance request to /api/ask for Socratic questioning'); const guidancePrompt = this.currentLanguage === 'de' - ? `Ein Kind hat "${answer}" geantwortet auf die Frage "${currentQuestion}" über das Thema "${originalQuestion}". Führe es durch Socratic Fragen zur Entdeckung, ohne direkte Antworten zu geben.` - : `A child answered "${answer}" to the question "${currentQuestion}" about the topic "${originalQuestion}". Guide them through Socratic questions to discovery without giving direct answers.`; + ? `Ein Kind hat "${answer}" geantwortet auf die Frage "${currentQuestion}" über das Thema "${originalQuestion}". Das Kind weiß die Antwort nicht. Führe es durch 2-3 aufbauende Socratic Fragen zur Entdeckung, ohne direkte Antworten zu geben. Beginne mit einfachen Beobachtungen, die das Kind kennt.` + : `A child answered "${answer}" to the question "${currentQuestion}" about the topic "${originalQuestion}". The child doesn't know the answer. Guide them through 2-3 building Socratic questions to discovery without giving direct answers. Start with simple observations the child would know.`; response = await fetch('/api/ask', { method: 'POST', @@ -647,9 +655,15 @@ class KidsAIExplorer { this.scrollToBottomSmoothly(); }, 100); - // Add choice buttons after AI response + // Determine next action based on response type setTimeout(() => { - this.addContinueChoiceButtons(); + if (data.guidance && data.guidance.steps && (isNegative || isDontKnow)) { + // For "don't know" responses with Socratic guidance, continue to next question immediately + this.continueToNextQuestion(); + } else { + // For substantial answers, show choice buttons + this.addContinueChoiceButtons(); + } }, 1500); } else { throw new Error(data.error || 'Failed to generate response'); diff --git a/html/kidsai/server.js b/html/kidsai/server.js index df51c63..9546e16 100755 --- a/html/kidsai/server.js +++ b/html/kidsai/server.js @@ -626,18 +626,19 @@ IMPORTANT: const answerLower = answer.toLowerCase(); let fallbackResponse; - if (answerLower.includes("don't know") || answerLower.includes("no idea") || answer.trim().length < 3) { + if (answerLower.includes("don't know") || answerLower.includes("weiß nicht") || answerLower.includes("keine ahnung") || + answerLower.includes("ich weiß es nicht") || answerLower === "warum" || answerLower === "why" || answer.trim().length < 5) { fallbackResponse = isGerman ? - "🌟 Das ist völlig in Ordnung! Nicht zu wissen bedeutet, dass wir zusammen etwas Neues entdecken können." : - "🌟 That's completely okay! Not knowing means we get to discover something new together."; + "🌟 Perfekt! Lass uns das gemeinsam herausfinden." : + "🌟 Perfect! Let's figure this out together."; } else if (answer.length < 15) { fallbackResponse = isGerman ? - `💡 Interessante Überlegung zu "${answer}"! Du denkst in die richtige Richtung.` : - `💡 Interesting thinking about "${answer}"! You're on the right track.`; + `💡 Guter Gedanke! Du bist auf dem richtigen Weg.` : + `💡 Good thinking! You're on the right track.`; } else { fallbackResponse = isGerman ? - `🎯 Ausgezeichnete Antwort! Du denkst wirklich gut über "${answer}" nach. Das zeigt, dass du das Konzept verstehst.` : - `🎯 Excellent answer! You're really thinking well about "${answer}". This shows you understand the concept.`; + `🎯 Ausgezeichnet! Du denkst wirklich wissenschaftlich.` : + `🎯 Excellent! You're thinking like a real scientist.`; } res.json({