Spaces:
Running
Running
import streamlit as st | |
from utils import get_chroma_client, get_embedding_function | |
# streamlit_app.py | |
import hmac | |
import streamlit as st | |
__import__("pysqlite3") | |
import sys | |
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") | |
st.set_page_config(page_title="Hello", page_icon="π", layout="wide") | |
def check_password(): | |
"""Returns `True` if the user had the correct password.""" | |
def password_entered(): | |
"""Checks whether a password entered by the user is correct.""" | |
if hmac.compare_digest(st.session_state["password"], st.secrets["password"]): | |
st.session_state["password_correct"] = True | |
del st.session_state["password"] # Don't store the password. | |
else: | |
st.session_state["password_correct"] = False | |
# Return True if the password is validated. | |
if st.session_state.get("password_correct", False): | |
return True | |
# Show input for password. | |
st.text_input( | |
"Password", type="password", on_change=password_entered, key="password" | |
) | |
if "password_correct" in st.session_state: | |
st.error("π Password incorrect") | |
return False | |
if not check_password(): | |
st.stop() # Do not continue if check_password is not True. | |
# Main Streamlit app starts here | |
st.write("# Brian Knowledge Base System! π") | |
client = get_chroma_client() | |
default_embedding_function = get_embedding_function() | |