-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhome.py
68 lines (59 loc) · 1.89 KB
/
home.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import streamlit as st
import streamlit_authenticator as stauth
# import yaml
# from yaml.loader import SafeLoader
st.set_page_config(
page_title="LLM Collection for Office",
page_icon="💀",
)
# with open("./config.ymal") as file:
# config = yaml.load(file, Loader=SafeLoader)
username = list(st.secrets["credentials"]["usernames"].keys())[0]
credentials = {
"credentials": {
"usernames": {
username: {
"email": st.secrets["credentials"]["usernames"][username]["email"],
"name": st.secrets["credentials"]["usernames"][username]["name"],
"password": st.secrets["credentials"]["usernames"][username][
"password"
],
}
}
},
"cookie": {
"expiry_days": st.secrets["cookie"]["expiry_days"],
"key": st.secrets["cookie"]["key"],
"name": st.secrets["cookie"]["name"],
},
"preauthorized": {
"emails": st.secrets["preauthorized"]["emails"],
},
}
authenticator = stauth.Authenticate(
# config["credentials"],
# config["cookie"]["name"],
# config["cookie"]["key"],
# config["cookie"]["expiry_days"],
# config["preauthorized"],
credentials["credentials"],
credentials["cookie"]["name"],
credentials["cookie"]["key"],
credentials["cookie"]["expiry_days"],
credentials["preauthorized"],
)
name, authentication_status, username = authenticator.login()
if "authentication_status" not in st.session_state:
st.session_state["authentication_status"] = authentication_status
if authentication_status:
authenticator.logout("Logout", "main")
st.write(f"Welcome *{name}*")
st.markdown(
"""
# 1. Groq Llama3
"""
)
elif authentication_status == False:
st.error("Username/password is incorrect")
elif authentication_status == None:
st.warning("Please enter your username and password")