Enhance definition detection for location and relationship questions

IMPROVEMENTS:
- Added detection for 'was hat...zu tun' (what does...have to do with), 'wo ist' (where is), 'wo sind' (where are)
- Added detection for 'wie funktioniert' (how does) and 'warum ist' (why is)
- Enhanced server-side definition prompts to handle location and relationship questions
- Added topic-specific fallback explanations for Earth/seasons/temperature questions
- Improved OpenAI prompt context for better definition responses

This ensures children asking direct questions like 'wo ist die erde?' or 'was hat die position damit zu tun?' get explanations instead of more Socratic questions.
This commit is contained in:
root
2025-06-30 15:34:45 +02:00
parent 7e8ab4bae1
commit 9a7db8cff1
2 changed files with 10 additions and 1 deletions

View File

@@ -661,6 +661,11 @@ class KidsAIExplorer {
const isAskingForDefinition = answerLower.startsWith('was ist') || answerLower.startsWith('what is') ||
answerLower.includes('was bedeutet') || answerLower.includes('what does') ||
answerLower.includes('was heißt') || answerLower.includes('what means') ||
answerLower.includes('was hat') || answerLower.includes('what has') ||
answerLower.includes('wo ist') || answerLower.includes('where is') ||
answerLower.includes('wo sind') || answerLower.includes('where are') ||
answerLower.includes('wie funktioniert') || answerLower.includes('how does') ||
answerLower.includes('warum ist') || answerLower.includes('why is') ||
(answerLower.includes('?') && (answerLower.includes('ist ein') || answerLower.includes('is a')));
let response;

View File

@@ -612,6 +612,10 @@ The child is expressing confusion and needs help understanding. Provide a clear,
confusionFallback = isGerman ?
'Vögel können fliegen, weil sie besondere Körperteile haben! Ihre Flügel sind leicht aber stark, ihre Knochen sind hohl (wie Strohhalme), und sie haben kräftige Brustmuskeln, die die Flügel bewegen. Wenn sie die Flügel auf und ab schlagen, drücken sie die Luft nach unten, und das hebt sie nach oben - wie beim Schwimmen, aber in der Luft! Du kannst das ausprobieren: Wedel mit den Armen und spür, wie du die Luft bewegst! 🐦' :
'Birds can fly because they have special body parts! Their wings are light but strong, their bones are hollow (like straws), and they have powerful chest muscles that move the wings. When they flap their wings up and down, they push air downward, and that lifts them up - like swimming, but in the air! You can try this: wave your arms and feel how you move the air! 🐦';
} else if (topicLower.includes('jahreszeiten') || topicLower.includes('seasons') || topicLower.includes('winter') || topicLower.includes('sommer') || topicLower.includes('summer') || topicLower.includes('erde') || topicLower.includes('earth') || topicLower.includes('position') || topicLower.includes('heiß') || topicLower.includes('kalt') || topicLower.includes('hot') || topicLower.includes('cold')) {
confusionFallback = isGerman ?
'Die Erde ist wie ein Ball, der um die Sonne kreist! Sie ist etwas schief geneigt, wie ein Ball, der leicht zur Seite hängt. Wenn unser Teil der Erde zur Sonne geneigt ist, bekommen wir mehr Sonnenlicht und es wird Sommer. Wenn wir von der Sonne weg geneigt sind, bekommen wir weniger Licht und es wird Winter! Du kannst das mit einer Taschenlampe und einem Ball ausprobieren - halte den Ball schief und leuchte ihn an! 🌍☀️' :
'The Earth is like a ball that goes around the Sun! It\'s tilted a bit, like a ball that hangs slightly to one side. When our part of Earth tilts toward the Sun, we get more sunlight and it becomes summer. When we tilt away from the Sun, we get less light and it becomes winter! You can try this with a flashlight and a ball - hold the ball tilted and shine light on it! 🌍☀️';
} else if (topicLower.includes('regenbogen') || topicLower.includes('rainbow') || topicLower.includes('farben') || topicLower.includes('colors')) {
confusionFallback = isGerman ?
'Das passiert, weil Sonnenlicht aus vielen verschiedenen Farben besteht! Wenn Licht durch Regentropfen geht, werden diese Farben getrennt - wie bei einem Prisma. Du kannst das selbst ausprobieren: Halte ein Glas Wasser ins Sonnenlicht und schau, welche Farben entstehen! 🌈' :
@@ -636,7 +640,7 @@ The child is expressing confusion and needs help understanding. Provide a clear,
CHILD'S QUESTION: "${answer}"
CONTEXT: We were discussing "${question}"
The child is asking for a definition or explanation. Provide a clear, child-friendly answer with simple examples and invite further questions.`;
The child is asking for a definition, explanation, or clarification about location/relationships. Provide a clear, child-friendly answer with simple examples and invite further questions. If asking about location (where is X?), explain in simple terms. If asking about relationships (what does X have to do with Y?), explain the connection clearly.`;
// Try OpenAI first for definitions
if (process.env.OPENAI_API_KEY) {