From 578bccd745a06fb61bb23d46b39df18ce3c1eb5f Mon Sep 17 00:00:00 2001 From: root Date: Sun, 29 Jun 2025 17:23:43 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=AF=20IMPROVE:=20Contextual=20encourag?= =?UTF-8?q?ements=20and=20pneumatic=20responses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added pneumatic hammer responses to ai-responses.js for engineering questions - Enhanced server encouragements to be contextual based on question topic - Removed generic 'smart question' responses - Added specific responses for compressed air, air pressure, direction, etc. - Server now provides topic-specific encouragements (pneumatic, bicycle, car) - Better mechanical engineering focused feedback for students --- html/kidsai/ai-responses.js | 10 ++++++ html/kidsai/script-new.js | 17 +++++++++ html/kidsai/server.js | 70 +++++++++++++++++++++++++++---------- 3 files changed, 79 insertions(+), 18 deletions(-) diff --git a/html/kidsai/ai-responses.js b/html/kidsai/ai-responses.js index 3445f3b..9fc6f0c 100644 --- a/html/kidsai/ai-responses.js +++ b/html/kidsai/ai-responses.js @@ -75,6 +75,16 @@ const AIResponses = { connectControl: "🔧 Excellent mechanical thinking! You understand that cars have systems that connect and control different parts!" }, + // Pneumatic tools and compressed air + pneumatic: { + compressedAir: "🔧 Excellent! You understand that compressed air is the key! That's exactly right - pneumatic tools use compressed air as their power source!", + airPressure: "💨 Perfect! Air pressure is exactly what makes pneumatic tools so powerful. You're thinking like an engineer!", + direction: "🎯 Great reasoning! You understand that directing the compressed air in a specific direction creates the force. That's brilliant mechanical thinking!", + balloon: "🎈 Fantastic connection! Just like a balloon, pneumatic tools use air pressure - but instead of inflating, they use that pressure to create powerful motion!", + release: "⚡ Yes! The controlled release of compressed air is what creates the hammer's powerful strikes. You've got the concept!", + general: "🔨 You're thinking about the mechanics of pneumatic tools - that's exactly the kind of engineering thinking we need!" + }, + // Generic responses based on answer quality (last resort) generic: { veryDetailed: "🌟 I appreciate your detailed explanation! You're really working through this systematically.", diff --git a/html/kidsai/script-new.js b/html/kidsai/script-new.js index fece8fb..e09653c 100644 --- a/html/kidsai/script-new.js +++ b/html/kidsai/script-new.js @@ -671,6 +671,23 @@ class KidsAIExplorer { return AIResponses.mechanical.connectControl; } + // PNEUMATIC tools responses + if (questionLower.includes('pneumatic') || questionLower.includes('compressed air') || questionLower.includes('air hammer')) { + if (answerLower.includes('compress') && answerLower.includes('air')) { + return AIResponses.pneumatic.compressedAir; + } else if (answerLower.includes('air pressure') || answerLower.includes('pressure')) { + return AIResponses.pneumatic.airPressure; + } else if (answerLower.includes('direction') || answerLower.includes('releasing')) { + return AIResponses.pneumatic.direction; + } else if (answerLower.includes('balloon') || answerLower.includes('inflate')) { + return AIResponses.pneumatic.balloon; + } else if (answerLower.includes('release') || answerLower.includes('strikes')) { + return AIResponses.pneumatic.release; + } else { + return AIResponses.pneumatic.general; + } + } + // Generic responses based on answer quality and engagement if (answer.length > 25) { return AIResponses.generic.veryDetailed; diff --git a/html/kidsai/server.js b/html/kidsai/server.js index 90d416d..45f48f7 100644 --- a/html/kidsai/server.js +++ b/html/kidsai/server.js @@ -157,7 +157,7 @@ async function getOpenAIGuidance(question, language) { return { type: 'ai-powered', steps: steps, - encouragement: getRandomEncouragement(language), + encouragement: getRandomEncouragement(language, question), source: 'OpenAI GPT-3.5' }; @@ -253,7 +253,7 @@ Format: 1. [question] 2. [question] 3. [question]`; return { type: 'ai-powered', steps: steps, - encouragement: getRandomEncouragement(language), + encouragement: getRandomEncouragement(language, question), source: `Hugging Face (${model.split('/')[1]})` }; } @@ -339,7 +339,7 @@ function getFallbackGuidance(question, language) { return { type: 'topic-specific', steps: birdQuestions, - encouragement: getRandomEncouragement(language), + encouragement: getRandomEncouragement(language, question), source: 'Educational Framework' }; } @@ -358,7 +358,7 @@ function getFallbackGuidance(question, language) { return { type: 'topic-specific', steps: skyQuestions, - encouragement: getRandomEncouragement(language), + encouragement: getRandomEncouragement(language, question), source: 'Educational Framework' }; } @@ -379,24 +379,58 @@ function getFallbackGuidance(question, language) { return { type: 'rule-based', steps: fallbackSteps, - encouragement: getRandomEncouragement(language), + encouragement: getRandomEncouragement(language, question), source: 'Educational Framework' }; } -// Get random encouragement -function getRandomEncouragement(language) { - const encouragements = language === 'de' ? [ - "Großartige Frage! Du denkst wie ein echter Forscher! 🔬", - "Super! Lass uns das zusammen herausfinden! 🚀", - "Wow, das ist eine kluge Frage! 🤔", - "Du bist auf dem richtigen Weg! 🌟" - ] : [ - "Great question! You're thinking like a real scientist! 🔬", - "Awesome! Let's figure this out together! 🚀", - "Wow, that's a smart question! 🤔", - "You're on the right track! 🌟" - ]; +// Get contextual encouragement based on question content +function getRandomEncouragement(language, question = '') { + const questionLower = question.toLowerCase(); + + // Contextual encouragements based on question topic + let encouragements; + + if (questionLower.includes('pneumatic') || questionLower.includes('air hammer')) { + encouragements = language === 'de' ? [ + "Faszinierende Frage über pneumatische Werkzeuge! 🔧", + "Du denkst wie ein Ingenieur! Lass uns das erforschen! ⚙️", + "Großartig! Mechanische Systeme sind spannend! 🛠️" + ] : [ + "Fascinating question about pneumatic tools! 🔧", + "You're thinking like an engineer! Let's explore this! ⚙️", + "Great! Mechanical systems are exciting! 🛠️" + ]; + } else if (questionLower.includes('bicycle') || questionLower.includes('bike')) { + encouragements = language === 'de' ? [ + "Perfekt! Fahrräder sind großartige Lernwerkzeuge! 🚴‍♂️", + "Ausgezeichnet! Du verstehst mechanische Systeme! ⚙️" + ] : [ + "Perfect! Bicycles are great learning tools! 🚴‍♂️", + "Excellent! You understand mechanical systems! ⚙️" + ]; + } else if (questionLower.includes('car') || questionLower.includes('automobile')) { + encouragements = language === 'de' ? [ + "Interessant! Autos haben faszinierende Mechanismen! �", + "Du erforschst komplexe Systeme! 🔧" + ] : [ + "Interesting! Cars have fascinating mechanisms! 🚗", + "You're exploring complex systems! 🔧" + ]; + } else { + // General encouragements (more varied and less generic) + encouragements = language === 'de' ? [ + "Interessante Frage! Lass uns das erforschen! �", + "Du denkst wie ein echter Forscher! 🔬", + "Fantastisch! Lass uns das zusammen herausfinden! 🚀", + "Neugier ist der Schlüssel zum Lernen! 🌟" + ] : [ + "Interesting question! Let's explore this! 🔍", + "You're thinking like a real researcher! 🔬", + "Fantastic! Let's figure this out together! 🚀", + "Curiosity is the key to learning! 🌟" + ]; + } return encouragements[Math.floor(Math.random() * encouragements.length)]; }