diff --git a/src/hint_generation/app.py b/src/hint_generation/app.py index 7d77ecc..8359a00 100644 --- a/src/hint_generation/app.py +++ b/src/hint_generation/app.py @@ -131,13 +131,15 @@ def instantiate_session(): retrieval_strategy = retrieval_strategies.MappedEmbeddingRetrievalStrategy(slot_map) st.session_state.hint_prompt_manager.set_retrieval_strategy(retrieval_strategy) - query_params = st.experimental_get_query_params() - if "show_expert_controls" in query_params: - if query_params["show_expert_controls"][0].lower() == "true": + if "show_expert_controls" in st.query_params: + if st.query_params["show_expert_controls"][0].lower() == "true": st.session_state.show_expert_controls = True if "is_openai_key_set" not in st.session_state or not st.session_state.is_openai_key_set: - openai.api_key = st.secrets["OPENAI_API_KEY"] + if "openai_api_key" in st.query_params: + openai.api_key = st.query_params["openai_api_key"] + else: + openai.api_key = st.secrets["OPENAI_API_KEY"] st.session_state.is_openai_key_set = True @@ -166,7 +168,7 @@ def make_sidebar(): we use sample micro-lessons, problems, and common incorrect answers provided by [Rising Academies](https://www.risingacademies.com/), a pre-algebra textbook available for free from [OpenStax](https://openstax.org/details/books/prealgebra-2e), and a list of common math misconceptions assembled by [Nancy Otero](https://github.com/creature-ai/math-misconceptions). -Have more questions or comments? Please contact Zach () with your thoughts! +Have more questions or comments? Please contact Zach () with your thoughts! """, ) diff --git a/src/streamlit_app/auth_utils.py b/src/streamlit_app/auth_utils.py index 0ed1d5f..a726817 100644 --- a/src/streamlit_app/auth_utils.py +++ b/src/streamlit_app/auth_utils.py @@ -90,10 +90,9 @@ def check_is_authorized(allow_openai_key: bool = False, markdown_header: str = " if "is_authorized" not in st.session_state or not st.session_state.is_authorized: st.session_state.is_authorized = False if "is_authorized_via_token" not in st.session_state: - query_params = st.experimental_get_query_params() st.session_state.is_authorized_via_token = False - if "auth_token" in query_params and "AUTH_TOKEN" in st.secrets: - auth_token = query_params["auth_token"][0] + if "auth_token" in st.query_params and "AUTH_TOKEN" in st.secrets: + auth_token = st.query_params["auth_token"] if passwd_check(st.secrets["AUTH_TOKEN"], auth_token): st.session_state.is_authorized_via_token = True if st.session_state.is_authorized_via_token: diff --git "a/src/\360\237\244\226_Math_QA.py" "b/src/\360\237\244\226_Math_QA.py" index 0fcbc23..3f49370 100644 --- "a/src/\360\237\244\226_Math_QA.py" +++ "b/src/\360\237\244\226_Math_QA.py" @@ -136,9 +136,8 @@ def instantiate_session(): if "prompt_manager" not in st.session_state: st.session_state.prompt_manager = prompt_utils.PromptManager() - query_params = st.experimental_get_query_params() - if "show_expert_controls" in query_params: - if query_params["show_expert_controls"][0].lower() == "true": + if "show_expert_controls" in st.query_params: + if st.query_params["show_expert_controls"].lower() == "true": st.session_state.show_expert_controls = True if "student_queries" not in st.session_state: diff --git a/tests/unit/test_hint_generation_app.py b/tests/unit/test_hint_generation_app.py index aee9364..3d98ad0 100644 --- a/tests/unit/test_hint_generation_app.py +++ b/tests/unit/test_hint_generation_app.py @@ -14,9 +14,10 @@ def test_hint_generation_app(): at.secrets["OPENAI_API_KEY"] = "test-key" at.run() assert not at.exception - assert not at.session_state.is_authorized + assert "is_authorized" not in at.session_state or not at.session_state.is_authorized # attempt to log in - at.text_input(key=auth_utils.PASSWORD_TEXT_INPUT_KEY).input(password).run() - assert not at.exception - assert at.session_state.is_authorized + # note: this is deprecated, because we turend off passwords for this demo + # at.text_input(key=auth_utils.PASSWORD_TEXT_INPUT_KEY).input(password).run() + # assert not at.exception + # assert at.session_state.is_authorized