Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,29 +6,6 @@ import uuid
|
|
6 |
import firebase_admin
|
7 |
from firebase_admin import credentials, firestore
|
8 |
|
9 |
-
# ------------------ Authentication ------------------
|
10 |
-
VALID_USERS = {
|
11 |
-
"[email protected]": "Pass.123",
|
12 |
-
}
|
13 |
-
|
14 |
-
def login():
|
15 |
-
st.title("π Login Required")
|
16 |
-
email = st.text_input("Email")
|
17 |
-
password = st.text_input("Password", type="password")
|
18 |
-
if st.button("Login"):
|
19 |
-
if VALID_USERS.get(email) == password:
|
20 |
-
st.session_state.authenticated = True
|
21 |
-
st.rerun()
|
22 |
-
else:
|
23 |
-
st.error("β Incorrect email or password.")
|
24 |
-
|
25 |
-
if "authenticated" not in st.session_state:
|
26 |
-
st.session_state.authenticated = False
|
27 |
-
|
28 |
-
if not st.session_state.authenticated:
|
29 |
-
login()
|
30 |
-
st.stop()
|
31 |
-
|
32 |
# π Firebase setup
|
33 |
if not firebase_admin._apps:
|
34 |
cred = credentials.Certificate("firebase-service-account.json")
|
@@ -54,7 +31,12 @@ st.markdown("""
|
|
54 |
<style>
|
55 |
.block-container {padding-top: 1rem; padding-bottom: 0rem;}
|
56 |
header {visibility: hidden;}
|
57 |
-
.stChatMessage {
|
|
|
|
|
|
|
|
|
|
|
58 |
.stChatMessage[data-testid="stChatMessage-user"] {
|
59 |
background: #f4f4f4; color: #000000;
|
60 |
}
|
@@ -62,21 +44,24 @@ st.markdown("""
|
|
62 |
background: #013D52; color: #ffffff;
|
63 |
}
|
64 |
.stChatMessage strong { color: #E2003C; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
</style>
|
66 |
""", unsafe_allow_html=True)
|
67 |
|
68 |
st.markdown("""
|
69 |
<div style='text-align: center; margin-top: 20px; margin-bottom: -10px;'>
|
70 |
-
<span style='display: inline-flex; align-items: center; gap: 8px;'>
|
71 |
-
<
|
72 |
-
|
73 |
-
<path d="M41.31,87.813A13.457,13.457,0,1,1,54.767,101.27..." fill="#013d52"></path>
|
74 |
-
</g>
|
75 |
-
<g id="g-icon">
|
76 |
-
<path d="M463.17,17.088,439,37.37,455.636,0l9.321,12.3L469.314.641l8.131,10.734L459.291,27.47Z" transform="translate(-303.988)" fill="#E2003C"></path>
|
77 |
-
</g>
|
78 |
-
</svg>
|
79 |
-
<span style='font-size: 12px; color: gray;'>Powered by Motus Holdings</span>
|
80 |
</span>
|
81 |
</div>
|
82 |
""", unsafe_allow_html=True)
|
@@ -116,6 +101,7 @@ with input_col:
|
|
116 |
user_input = st.chat_input("Type your message here...")
|
117 |
|
118 |
with clear_col:
|
|
|
119 |
if st.button("ποΈ", key="clear-chat", help="Clear Chat"):
|
120 |
try:
|
121 |
user_doc_ref = db.collection("users").document(user_id)
|
@@ -126,6 +112,7 @@ with clear_col:
|
|
126 |
st.rerun()
|
127 |
except Exception as e:
|
128 |
st.error(f"Failed to clear chat: {e}")
|
|
|
129 |
|
130 |
thread_id = get_or_create_thread_id()
|
131 |
display_chat_history()
|
@@ -148,4 +135,4 @@ if user_input:
|
|
148 |
|
149 |
save_message("assistant", assistant_message)
|
150 |
time.sleep(0.5)
|
151 |
-
st.rerun()
|
|
|
6 |
import firebase_admin
|
7 |
from firebase_admin import credentials, firestore
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# π Firebase setup
|
10 |
if not firebase_admin._apps:
|
11 |
cred = credentials.Certificate("firebase-service-account.json")
|
|
|
31 |
<style>
|
32 |
.block-container {padding-top: 1rem; padding-bottom: 0rem;}
|
33 |
header {visibility: hidden;}
|
34 |
+
.stChatMessage {
|
35 |
+
max-width: 85%;
|
36 |
+
border-radius: 12px;
|
37 |
+
padding: 10px;
|
38 |
+
margin-bottom: 12px;
|
39 |
+
}
|
40 |
.stChatMessage[data-testid="stChatMessage-user"] {
|
41 |
background: #f4f4f4; color: #000000;
|
42 |
}
|
|
|
44 |
background: #013D52; color: #ffffff;
|
45 |
}
|
46 |
.stChatMessage strong { color: #E2003C; }
|
47 |
+
@media screen and (max-width: 768px) {
|
48 |
+
.stChatInputContainer {
|
49 |
+
width: 95% !important;
|
50 |
+
margin: auto;
|
51 |
+
display: block;
|
52 |
+
}
|
53 |
+
.clear-chat-container {
|
54 |
+
display: none !important;
|
55 |
+
}
|
56 |
+
}
|
57 |
</style>
|
58 |
""", unsafe_allow_html=True)
|
59 |
|
60 |
st.markdown("""
|
61 |
<div style='text-align: center; margin-top: 20px; margin-bottom: -10px;'>
|
62 |
+
<span style='display: inline-flex; align-items: center; gap: 8px; flex-direction: column;'>
|
63 |
+
<img src='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxANBhEQEA8NEBASDQ0REA0VDRAPEA4SIB0iIiAdHx8kKDQkJCYxJx8fLTstMT0tMDdDIys0TT9APzQ5NzcBCgoKDg0OGhAQGi0dHR8tKy0tLS0tLS0tKystLS0rLS0tLS0tKy0tLS0tLSsrLS0tKysrLS0tLS0tKy03LS0tN//AABEIAMgAyAMBEQACEQEDEQH/xAAcAAEAAgMBAQEAAAAAAAAAAAAABQYBBAcDAgj/xABAEAACAQMBBgMDBgsJAAAAAAAAAQIDBBEFBgcSITFRE4GRQWGxIlJxocHRFBcjJDI2VGJ0otIlJjNCU4KTlMP/xAAbAQEAAwEBAQEAAAAAAAAAAAAAAQIDBAUGB//EACURAQACAgIBBQEBAQEBAAAAAAABAgMRBCESBRMxMkEigVGxBv/aAAwDAQACEQMRAD8A...TRUNCATED FOR BREVITY' width='140' style='margin-bottom: 5px;' />
|
64 |
+
<span style='font-size: 13px; color: gray;'>Powered by Motus Holdings</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
</span>
|
66 |
</div>
|
67 |
""", unsafe_allow_html=True)
|
|
|
101 |
user_input = st.chat_input("Type your message here...")
|
102 |
|
103 |
with clear_col:
|
104 |
+
st.markdown("<div class='clear-chat-container'>", unsafe_allow_html=True)
|
105 |
if st.button("ποΈ", key="clear-chat", help="Clear Chat"):
|
106 |
try:
|
107 |
user_doc_ref = db.collection("users").document(user_id)
|
|
|
112 |
st.rerun()
|
113 |
except Exception as e:
|
114 |
st.error(f"Failed to clear chat: {e}")
|
115 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
116 |
|
117 |
thread_id = get_or_create_thread_id()
|
118 |
display_chat_history()
|
|
|
135 |
|
136 |
save_message("assistant", assistant_message)
|
137 |
time.sleep(0.5)
|
138 |
+
st.rerun()
|