Fix confusion detection: 'mehr fällt mir nicht ein' now properly triggers explanations instead of more questions, and uses correct API endpoint

This commit is contained in:
root
2025-06-30 14:07:00 +02:00
parent 9018d8772e
commit f610db5c6e

View File

@@ -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 {