Fix clumsy AI responses with truly contextual feedback
- Handle 'yes/no' answers appropriately instead of generic responses - Provide proper feedback for 'I don't know' and help-seeking questions - Give meaningful responses when user says 'the engine' vs 'clutch' - Acknowledge when user is on right track vs completely off - Add bicycle/mechanical connection responses for building concepts - Fix traffic light and gear-switching specific responses - Stop giving 'good thinking' to users who say 'no, what is it?' - Make AI responses match the actual content and intent of user answers - Create natural teaching flow that builds on user's existing knowledge
This commit is contained in:
@@ -553,52 +553,88 @@ class KidsAIExplorer {
|
|||||||
generateContextualResponse(answer, questionIndex) {
|
generateContextualResponse(answer, questionIndex) {
|
||||||
const answerLower = answer.toLowerCase();
|
const answerLower = answer.toLowerCase();
|
||||||
const currentQuestion = this.questions[questionIndex];
|
const currentQuestion = this.questions[questionIndex];
|
||||||
|
const questionLower = currentQuestion ? currentQuestion.toLowerCase() : '';
|
||||||
|
|
||||||
// Analyze the answer and generate a contextual response
|
// Handle "I don't know" or help-seeking responses
|
||||||
if (!answer || answer.length < 3 || answerLower.includes('don\'t know') || answerLower.includes('no idea')) {
|
if (answerLower.includes('don\'t know') || answerLower.includes('no idea') ||
|
||||||
return "That's perfectly okay! Not knowing something is the first step to learning. Let's explore this together! 🌟";
|
answerLower.includes('what is it') || answerLower.includes('tell me') ||
|
||||||
|
(answerLower === 'no' && questionLower.includes('heard of'))) {
|
||||||
|
return "That's perfectly fine! 🤗 Not knowing something just means we're about to learn something new together. Let's keep exploring!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Topic-specific responses based on the question context
|
// Handle very short positive answers like "yes"
|
||||||
if (currentQuestion && currentQuestion.toLowerCase().includes('clutch')) {
|
if (answerLower === 'yes' || answerLower === 'yeah' || answerLower === 'yep') {
|
||||||
if (answerLower.includes('separate') || answerLower.includes('disconnect') || answerLower.includes('gearbox') || answerLower.includes('engine')) {
|
if (questionLower.includes('bicycle') || questionLower.includes('pedal')) {
|
||||||
return "🎯 Excellent! You're absolutely right - the clutch does separate the engine from the gearbox! You clearly understand the basic function. That's a great foundation!";
|
return "Great! 🚴♂️ Since you understand how bicycles work, you're already thinking about mechanical connections. That's exactly the kind of thinking we need!";
|
||||||
} else if (answerLower.includes('gear') || answerLower.includes('shift')) {
|
} else if (questionLower.includes('heard of') || questionLower.includes('know')) {
|
||||||
return "👍 Yes, exactly! You understand that it's all about changing gears. The clutch is the key component that makes smooth gear changes possible!";
|
return "Excellent! 👍 Your knowledge will help us build on these concepts together!";
|
||||||
} else if (answerLower.includes('pedal') || answerLower.includes('foot') || answerLower.includes('press')) {
|
|
||||||
return "💡 Great observation! Yes, the clutch pedal is how the driver controls it. You're thinking about the practical side of how it works!";
|
|
||||||
} else {
|
} else {
|
||||||
return "🤔 Interesting thought! You're on the right track. The clutch is indeed a crucial part of how cars work!";
|
return "Perfect! 🌟 I can see you're following along. Let's dive a bit deeper!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bird/flight topic responses
|
// Handle "no" responses
|
||||||
if (currentQuestion && (currentQuestion.toLowerCase().includes('bird') || currentQuestion.toLowerCase().includes('wing') || currentQuestion.toLowerCase().includes('fly'))) {
|
if (answerLower === 'no' || answerLower === 'nope') {
|
||||||
|
return "No problem at all! 😊 That's why we're exploring this together - to discover new things!";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Topic-specific contextual responses
|
||||||
|
if (questionLower.includes('bicycle') || questionLower.includes('pedal') || questionLower.includes('chain')) {
|
||||||
|
if (answerLower.includes('pedal') || answerLower.includes('chain') || answerLower.includes('wheel')) {
|
||||||
|
return "<22>♂️ Excellent! You understand the connection between pedals, chain, and wheels. That mechanical connection concept is key!";
|
||||||
|
} else if (answerLower.includes('gear') || answerLower.includes('speed')) {
|
||||||
|
return "👍 Yes! You're thinking about how we control speed and power - that's exactly right!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (questionLower.includes('car') && questionLower.includes('bicycle')) {
|
||||||
|
if (answerLower.includes('engine')) {
|
||||||
|
return "<22> You're thinking about the engine - that's the power source! But I'm thinking of a specific part that works between the engine and wheels, kind of like how bike pedals connect to the chain.";
|
||||||
|
} else if (answerLower.includes('gear') || answerLower.includes('transmission')) {
|
||||||
|
return "🎯 Great thinking! You're absolutely on the right track with gears and transmission systems!";
|
||||||
|
} else if (answerLower.includes('pedal') || answerLower.includes('brake')) {
|
||||||
|
return "🦶 Good connection! You're thinking about pedals in cars. There are actually multiple pedals that do different things!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (questionLower.includes('clutch') || questionLower.includes('gears') || questionLower.includes('switch gears')) {
|
||||||
|
if (answerLower.includes('clutch')) {
|
||||||
|
return "🎯 Perfect! You know about the clutch! That's exactly what I was thinking of - the component that helps with smooth gear changes!";
|
||||||
|
} else if (answerLower.includes('transmission') || answerLower.includes('gearbox')) {
|
||||||
|
return "🔧 Excellent! You're thinking about the transmission system. The clutch is the part that connects and disconnects the engine from the gearbox!";
|
||||||
|
} else if (answerLower.includes('separate') || answerLower.includes('disconnect')) {
|
||||||
|
return "👍 Yes! You understand the separation concept - that's exactly what the clutch does!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (questionLower.includes('traffic light') || questionLower.includes('stopped') || questionLower.includes('engine running')) {
|
||||||
|
if (answerLower.includes('clutch') || answerLower.includes('neutral')) {
|
||||||
|
return "🚦 Brilliant! You understand that we need a way to keep the engine running while the car is stopped!";
|
||||||
|
} else if (answerLower.includes('brake') || answerLower.includes('park')) {
|
||||||
|
return "🛑 You're thinking about stopping the car, which is important! But I'm thinking of how the engine can keep running while the wheels aren't moving.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bird flight responses
|
||||||
|
if (questionLower.includes('bird') || questionLower.includes('wing') || questionLower.includes('fly')) {
|
||||||
if (answerLower.includes('push') || answerLower.includes('air') || answerLower.includes('lift')) {
|
if (answerLower.includes('push') || answerLower.includes('air') || answerLower.includes('lift')) {
|
||||||
return "🌟 Fantastic! You understand that it's all about air and creating lift! That's exactly how flight works - you're thinking like a scientist!";
|
return "<EFBFBD> Fantastic! You understand that it's all about air and creating lift! That's exactly how flight works!";
|
||||||
} else if (answerLower.includes('feather') || answerLower.includes('airflow')) {
|
} else if (answerLower.includes('feather') || answerLower.includes('airflow')) {
|
||||||
return "✨ Brilliant! Feathers and airflow are absolutely key to how birds fly. You're connecting the right concepts!";
|
return "✨ Brilliant! Feathers and airflow are absolutely key to how birds fly!";
|
||||||
} else if (answerLower.includes('flap') || answerLower.includes('move') || answerLower.includes('wing')) {
|
} else if (answerLower.includes('flap') || answerLower.includes('move')) {
|
||||||
return "🎯 Perfect! Wing movement is exactly what creates the forces that allow birds to fly. Great observation!";
|
return "🌟 Perfect! Wing movement creates the forces that allow birds to fly!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sky/color topic responses
|
// Generic responses based on answer quality and engagement
|
||||||
if (currentQuestion && (currentQuestion.toLowerCase().includes('sky') || currentQuestion.toLowerCase().includes('blue') || currentQuestion.toLowerCase().includes('color'))) {
|
if (answer.length > 25) {
|
||||||
if (answerLower.includes('light') || answerLower.includes('scatter') || answerLower.includes('blue')) {
|
return "🌟 I love your detailed thinking! You're really exploring this concept thoroughly. That kind of curiosity is what leads to great discoveries!";
|
||||||
return "💙 Excellent! You're thinking about light and how it behaves - that's exactly the scientific principle behind the blue sky!";
|
|
||||||
} else if (answerLower.includes('particle') || answerLower.includes('air') || answerLower.includes('atmosphere')) {
|
|
||||||
return "🔬 Great scientific thinking! The particles in our atmosphere do play a crucial role in what we see!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generic positive responses that acknowledge effort
|
|
||||||
if (answer.length > 20) {
|
|
||||||
return "🌟 Wonderful explanation! I can see you're really thinking deeply about this. Your detailed answer shows great curiosity!";
|
|
||||||
} else if (answer.length > 10) {
|
} else if (answer.length > 10) {
|
||||||
return "👍 Good thinking! You're on the right track. I like how you're approaching this problem!";
|
return "👍 Good observation! I can see you're thinking about this carefully. Your reasoning is developing nicely!";
|
||||||
|
} else if (answer.length > 3) {
|
||||||
|
return "<22> Interesting thought! You're engaging with the concept. Can you help me understand your thinking a bit more?";
|
||||||
} else {
|
} else {
|
||||||
return "💡 Nice start! Can you tell me a bit more about what you're thinking?";
|
return "🤔 I see you're thinking about this! Feel free to share whatever comes to mind - there are no wrong answers here!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user