alibicer's picture
Update app.py
bf0df63 verified
raw
history blame
987 Bytes
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