| | def respond(user_message, history): |
| | """ |
| | Handles user input and determines how the chatbot responds. |
| | - If the teacher selects a method, AI will **first ask them to explain their approach**. |
| | - AI will not provide a full solution immediately. |
| | - If the teacher already explained, AI will provide feedback and hints. |
| | """ |
| | user_message = user_message.strip().lower() |
| |
|
| | |
| | if user_message in ["bar model", "double number line", "equation"]: |
| | return get_prompt_for_method(user_message), history |
| | |
| | |
| | elif len(history) > 0 and history[-1] in [ |
| | get_prompt_for_method("bar model"), |
| | get_prompt_for_method("double number line"), |
| | get_prompt_for_method("equation") |
| | ]: |
| | last_method = history[-1].split("**")[1].split(" ")[0].lower() |
| | return get_feedback_for_method(last_method, user_message), history |
| | |
| | return "I didn’t quite understand that. Please select a method first (Bar Model, Double Number Line, or Equation).", history |
| |
|