Spaces:
Configuration error
Configuration error
Download streamlit_app/utils/state.py from rockysreenivasa/MathTutor: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/rockysreenivasa/MathTutor/resolve/main/streamlit_app/utils/state.py
- Command line
-
hf download hf://spaces/rockysreenivasa/MathTutor/streamlit_app/utils/state.py
-
curl -L -o state.py https://huggingface.co/spaces/rockysreenivasa/MathTutor/resolve/main/streamlit_app/utils/state.py
1.07 kB
| """Helpers to read/write tutor session state cleanly.""" | |
| import streamlit as st | |
| def init_tutor_state(): | |
| defaults = { | |
| "tutor_stage": "ask", # ask | explain | practice | test | result | |
| "current_query": "", | |
| "current_topic": "", | |
| "current_explanation": "", | |
| "current_session_id": None, | |
| "practice_problems": [], | |
| "test_questions": [], | |
| "test_answers": {}, | |
| "test_result": None, | |
| "new_badges": [], | |
| } | |
| for k, v in defaults.items(): | |
| if k not in st.session_state: | |
| st.session_state[k] = v | |
| def reset_tutor(): | |
| keys = [ | |
| "tutor_stage", "current_query", "current_topic", "current_explanation", | |
| "current_session_id", "practice_problems", "test_questions", | |
| "test_answers", "test_result", "new_badges", | |
| ] | |
| for k in keys: | |
| st.session_state.pop(k, None) | |
| init_tutor_state() | |
| def set_stage(stage: str): | |
| st.session_state["tutor_stage"] = stage | |
| def get_stage() -> str: | |
| return st.session_state.get("tutor_stage", "ask") | |