Skip to content

Commit

Permalink
Update streamlit version
Browse files Browse the repository at this point in the history
  • Loading branch information
levon003 committed Jun 7, 2024
1 parent d2a03f9 commit de66a6c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
12 changes: 7 additions & 5 deletions src/hint_generation/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 (<[email protected]>) with your thoughts!
Have more questions or comments? Please contact Zach (<zach@levi.digitalharbor.org>) with your thoughts!
""",
)

Expand Down
5 changes: 2 additions & 3 deletions src/streamlit_app/auth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions src/🤖_Math_QA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/test_hint_generation_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit de66a6c

Please sign in to comment.