File size: 987 Bytes
bf0df63 73b1050 12b9be3 4910ade bf0df63 12b9be3 bf0df63 12b9be3 bf0df63 866286c bf0df63 866286c bf0df63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
def respond(user_message, history, state_history):
if not user_message:
return "", history
# ✅ Retrieve stored method choice
last_method = state_history.get("selected_method", None)
# ✅ If the user selects a method, store it
if user_message.lower() in ["bar model", "double number line", "equation"]:
state_history["selected_method"] = user_message.lower() # Store method
response = get_prompt_for_method(user_message)
history.append((user_message, response))
return "", history, state_history
# ✅ If no method was selected, ask for one
if not last_method:
return "I didn’t understand that. Please select a method first (Bar Model, Double Number Line, or Equation).", history, state_history
# ✅ Process teacher’s reasoning and give feedback
response = get_feedback_for_method(last_method, user_message)
history.append((user_message, response))
return "", history, state_history
|