From f610db5c6ec5212a94b5a89fdf49848489f0a74e Mon Sep 17 00:00:00 2001 From: root Date: Mon, 30 Jun 2025 14:07:00 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20confusion=20detection:=20'mehr=20f=C3=A4l?= =?UTF-8?q?lt=20mir=20nicht=20ein'=20now=20properly=20triggers=20explanati?= =?UTF-8?q?ons=20instead=20of=20more=20questions,=20and=20uses=20correct?= =?UTF-8?q?=20API=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/kidsai/script-new.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/html/kidsai/script-new.js b/html/kidsai/script-new.js index b20e130..b40b895 100644 --- a/html/kidsai/script-new.js +++ b/html/kidsai/script-new.js @@ -443,7 +443,7 @@ class KidsAIExplorer { ); // Pure "don't know" without additional thinking - const isPureDontKnow = (hasDontKnowPhrase || isOnlyWhyQuestion || answer.trim().length < 5) && !hasSubstantialThinking; + const isPureDontKnow = (hasDontKnowPhrase || isOnlyWhyQuestion || answer.trim().length < 5) && !hasSubstantialThinking && !isExpressingConfusion; let response; @@ -652,18 +652,24 @@ class KidsAIExplorer { }) }); } else if (isExpressingConfusion) { - // If the child is confused, provide an explanation instead of more questions - console.log('📤 Sending explanation request to /api/explain'); + // Child is expressing confusion - provide a simple explanation + console.log('📤 Sending explanation request for confused child'); - response = await fetch('/api/explain', { + response = await fetch('/api/respond-to-answer', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ + answer: answer, question: currentQuestion, + originalTopic: originalQuestion, language: this.currentLanguage, - userAnswer: answer + context: 'confusion_explanation', + stepIndex: questionIndex, + instructions: this.currentLanguage === 'de' + ? 'Das Kind ist verwirrt und braucht eine einfache Erklärung. Gib eine klare, konkrete Antwort für Kinder. Erkläre das Konzept mit alltäglichen Beispielen. Verwende einfache Wörter und lade zum Ausprobieren ein. Keine weiteren Fragen stellen - erst erklären!' + : 'The child is confused and needs a simple explanation. Give a clear, concrete answer for children. Explain the concept with everyday examples. Use simple words and invite experimentation. Don\'t ask more questions - explain first!' }) }); } else {