|
def respond(user_message, history, state_history): |
|
if not user_message: |
|
return "", history |
|
|
|
|
|
last_method = state_history.get("selected_method", None) |
|
|
|
|
|
if user_message.lower() in ["bar model", "double number line", "equation"]: |
|
state_history["selected_method"] = user_message.lower() |
|
response = get_prompt_for_method(user_message) |
|
history.append((user_message, response)) |
|
return "", history, state_history |
|
|
|
|
|
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 |
|
|
|
|
|
response = get_feedback_for_method(last_method, user_message) |
|
history.append((user_message, response)) |
|
return "", history, state_history |
|
|