Critical fix: Detect explicit help requests like 'bitte verrate es mir', 'wie komme ich zur finalen antwort' and provide explanations instead of more questions

This commit is contained in:
root
2025-06-30 15:05:31 +02:00
parent f610db5c6e
commit cd9838cd15

View File

@@ -426,13 +426,21 @@ class KidsAIExplorer {
const isOnlyWhyQuestion = answerLower === 'warum' || answerLower === 'why' || answerLower === 'warum?' || answerLower === 'why?'; const isOnlyWhyQuestion = answerLower === 'warum' || answerLower === 'why' || answerLower === 'warum?' || answerLower === 'why?';
// Check if child is expressing confusion and needs explanation // Check if child is explicitly asking for help or the answer
const isAskingForHelp = answerLower.includes('bitte verrate es mir') || answerLower.includes('please tell me') ||
answerLower.includes('was bedeutet es') || answerLower.includes('what does it mean') ||
answerLower.includes('wie komme ich zur') || answerLower.includes('how do i get to') ||
answerLower.includes('finalen antwort') || answerLower.includes('final answer') ||
answerLower.includes('komme nicht drauf') || answerLower.includes("can't figure it out") ||
answerLower.includes('verrate mir') || answerLower.includes('tell me the answer');
// Enhanced confusion detection
const isExpressingConfusion = answerLower.includes('verstehe nicht') || answerLower.includes("don't understand") || const isExpressingConfusion = answerLower.includes('verstehe nicht') || answerLower.includes("don't understand") ||
answerLower.includes('versteh das nicht') || answerLower.includes('verstehe es nicht') || answerLower.includes('versteh das nicht') || answerLower.includes('verstehe es nicht') ||
answerLower.includes('ich verstehe nicht warum') || answerLower.includes("i don't understand why") || answerLower.includes('ich verstehe nicht warum') || answerLower.includes("i don't understand why") ||
answerLower.includes('aber ich verstehe nicht') || answerLower.includes("but i don't understand") || answerLower.includes('aber ich verstehe nicht') || answerLower.includes("but i don't understand") ||
answerLower.includes('fällt mir nicht ein') || answerLower.includes("can't think of") || answerLower.includes('fällt mir nicht ein') || answerLower.includes("can't think of") ||
answerLower.includes('mehr fällt mir nicht ein'); answerLower.includes('mehr fällt mir nicht ein') || isAskingForHelp;
// Check if it's a substantial answer (has thinking beyond just "don't know") // Check if it's a substantial answer (has thinking beyond just "don't know")
const hasSubstantialThinking = answer.length > 15 && ( const hasSubstantialThinking = answer.length > 15 && (
@@ -443,7 +451,7 @@ class KidsAIExplorer {
); );
// Pure "don't know" without additional thinking // Pure "don't know" without additional thinking
const isPureDontKnow = (hasDontKnowPhrase || isOnlyWhyQuestion || answer.trim().length < 5) && !hasSubstantialThinking && !isExpressingConfusion; const isPureDontKnow = (hasDontKnowPhrase || isOnlyWhyQuestion || answer.trim().length < 5) && !hasSubstantialThinking && !isExpressingConfusion && !isAskingForHelp;
let response; let response;
@@ -612,15 +620,23 @@ class KidsAIExplorer {
const isOnlyWhyQuestion = answerLower === 'warum' || answerLower === 'why' || answerLower === 'warum?' || answerLower === 'why?'; const isOnlyWhyQuestion = answerLower === 'warum' || answerLower === 'why' || answerLower === 'warum?' || answerLower === 'why?';
// Check if child is expressing confusion and needs explanation // Check if child is explicitly asking for help or the answer
const isAskingForHelp = answerLower.includes('bitte verrate es mir') || answerLower.includes('please tell me') ||
answerLower.includes('was bedeutet es') || answerLower.includes('what does it mean') ||
answerLower.includes('wie komme ich zur') || answerLower.includes('how do i get to') ||
answerLower.includes('finalen antwort') || answerLower.includes('final answer') ||
answerLower.includes('komme nicht drauf') || answerLower.includes("can't figure it out") ||
answerLower.includes('verrate mir') || answerLower.includes('tell me the answer');
// Enhanced confusion detection
const isExpressingConfusion = answerLower.includes('verstehe nicht') || answerLower.includes("don't understand") || const isExpressingConfusion = answerLower.includes('verstehe nicht') || answerLower.includes("don't understand") ||
answerLower.includes('versteh das nicht') || answerLower.includes('verstehe es nicht') || answerLower.includes('versteh das nicht') || answerLower.includes('verstehe es nicht') ||
answerLower.includes('ich verstehe nicht warum') || answerLower.includes("i don't understand why") || answerLower.includes('ich verstehe nicht warum') || answerLower.includes("i don't understand why") ||
answerLower.includes('aber ich verstehe nicht') || answerLower.includes("but i don't understand") || answerLower.includes('aber ich verstehe nicht') || answerLower.includes("but i don't understand") ||
answerLower.includes('fällt mir nicht ein') || answerLower.includes("can't think of") || answerLower.includes('fällt mir nicht ein') || answerLower.includes("can't think of") ||
answerLower.includes('mehr fällt mir nicht ein'); answerLower.includes('mehr fällt mir nicht ein') || isAskingForHelp;
// Check if it's a substantial answer (has thinking beyond just "don't know") // Check if it's a substantial answer (has thinking beyond "don't know")
const hasSubstantialThinking = answer.length > 15 && ( const hasSubstantialThinking = answer.length > 15 && (
answerLower.includes('vielleicht') || answerLower.includes('maybe') || answerLower.includes('könnte') || answerLower.includes('could') || answerLower.includes('vielleicht') || answerLower.includes('maybe') || answerLower.includes('könnte') || answerLower.includes('could') ||
answerLower.includes('hat es') || answerLower.includes('does it') || answerLower.includes('is it') || answerLower.includes('liegt es') || answerLower.includes('hat es') || answerLower.includes('does it') || answerLower.includes('is it') || answerLower.includes('liegt es') ||
@@ -651,9 +667,9 @@ class KidsAIExplorer {
language: this.currentLanguage language: this.currentLanguage
}) })
}); });
} else if (isExpressingConfusion) { } else if (isExpressingConfusion || isAskingForHelp) {
// Child is expressing confusion - provide a simple explanation // Child is expressing confusion or asking for help - provide a simple explanation
console.log('📤 Sending explanation request for confused child'); console.log('📤 Sending explanation request for confused child or help request');
response = await fetch('/api/respond-to-answer', { response = await fetch('/api/respond-to-answer', {
method: 'POST', method: 'POST',