ahmadsanafarooq commited on
Commit
3c606c4
·
verified ·
1 Parent(s): 0b58ed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +154 -36
app.py CHANGED
@@ -127,60 +127,176 @@ def detect_emotion(text):
127
 
128
  # Authentication UI
129
  def show_auth_page():
130
- st.set_page_config(page_title="DilBot - Login", page_icon="🧠")
131
- # --- PASTE YOUR CUSTOM CSS HERE FOR THE AUTH PAGE ---
 
132
  st.markdown("""
133
  <style>
134
- /* Example: Styling for the main container on the auth page */
135
  .stApp {
136
  background-color: #f0f2f6; /* Light grey background */
 
 
 
 
 
 
 
137
  }
138
  .main .block-container {
139
- padding-top: 2rem;
140
- padding-bottom: 2rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
- .stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
 
143
  font-size: 1.1em;
144
- font-weight: bold;
145
  }
146
- /* Style for text inputs */
147
- .stTextInput>div>div>input {
148
- border-radius: 8px;
149
- border: 1px solid #ccc;
150
- padding: 10px;
 
 
151
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  .stTextInput>label {
153
  font-weight: 600;
154
- color: #333;
 
 
 
 
155
  }
156
- /* Style for buttons */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  .stButton>button {
158
- background-color: #7289da; /* A shade of blue/purple */
159
  color: white;
160
- border-radius: 8px;
161
  border: none;
162
- padding: 10px 20px;
163
- font-size: 1em;
 
164
  font-weight: bold;
165
- transition: background-color 0.3s;
 
 
 
 
166
  }
167
  .stButton>button:hover {
168
- background-color: #5b6fb8;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
170
  </style>
171
  """, unsafe_allow_html=True)
172
- # --- END CUSTOM CSS ---
173
- st.title("🧠 DilBot - Emotional AI Companion")
174
- st.markdown("Welcome! Please login or create an account to continue.")
175
-
 
 
 
 
 
 
176
  tab1, tab2 = st.tabs(["Login", "Sign Up"])
177
-
178
  with tab1:
179
  st.subheader("Login to Your Account")
180
- login_username = st.text_input("Username", key="login_user")
181
- login_password = st.text_input("Password", type="password", key="login_pass")
182
-
183
- if st.button("Login", key="login_btn"):
 
184
  if login_username and login_password:
185
  success, message, is_admin = login(login_username, login_password)
186
  if success:
@@ -193,15 +309,15 @@ def show_auth_page():
193
  st.error(message)
194
  else:
195
  st.warning("Please fill in all fields")
196
-
197
  with tab2:
198
  st.subheader("Create New Account")
199
- signup_username = st.text_input("Choose Username", key="signup_user")
200
- signup_email = st.text_input("Email Address", key="signup_email")
201
- signup_password = st.text_input("Choose Password", type="password", key="signup_pass")
202
- signup_confirm = st.text_input("Confirm Password", type="password", key="signup_confirm")
203
-
204
- if st.button("Create Account", key="signup_btn"):
205
  if all([signup_username, signup_email, signup_password, signup_confirm]):
206
  if signup_password != signup_confirm:
207
  st.error("Passwords don't match!")
@@ -217,6 +333,8 @@ def show_auth_page():
217
  else:
218
  st.warning("Please fill in all fields")
219
 
 
 
220
  # Main app functions
221
  def build_user_vectorstore(username, quotes):
222
  """Build and save user-specific vectorstore"""
 
127
 
128
  # Authentication UI
129
  def show_auth_page():
130
+ st.set_page_config(page_title="DilBot - Login", page_icon="🧠", layout="centered") # Added layout="centered"
131
+
132
+ # --- UPDATED CUSTOM CSS FOR THE AUTH PAGE ---
133
  st.markdown("""
134
  <style>
135
+ /* Overall App Background & Font */
136
  .stApp {
137
  background-color: #f0f2f6; /* Light grey background */
138
+ font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; /* Modern, clean font */
139
+ color: #333333; /* Default text color */
140
+ }
141
+
142
+ /* Main Container for Auth Form (makes it look like a card) */
143
+ .stApp > header { /* Hide Streamlit's default header */
144
+ display: none;
145
  }
146
  .main .block-container {
147
+ max-width: 500px; /* Limit width for better aesthetics */
148
+ margin: auto; /* Center the container */
149
+ padding: 3rem 2rem; /* More padding top/bottom */
150
+ background-color: #ffffff; /* White background for the form card */
151
+ border-radius: 15px; /* Softer rounded corners */
152
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); /* Deeper shadow for card effect */
153
+ text-align: center; /* Center content within the card */
154
+ }
155
+
156
+ /* Titles and Subheaders */
157
+ h1 {
158
+ color: #7289da; /* DilBot's primary color */
159
+ font-size: 2.8em; /* Larger title */
160
+ font-weight: 700;
161
+ margin-bottom: 0.5rem;
162
  }
163
+ .stMarkdown p { /* For "Welcome! Please login..." */
164
+ color: #666666;
165
  font-size: 1.1em;
166
+ margin-bottom: 2rem;
167
  }
168
+ h2 { /* Subheaders for Login/Sign Up tabs */
169
+ color: #4A4A4A;
170
+ font-size: 1.7em;
171
+ font-weight: 600;
172
+ margin-top: 1.5rem;
173
+ margin-bottom: 1.5rem;
174
+ text-align: center;
175
  }
176
+
177
+ /* Tabs Styling */
178
+ .stTabs [data-baseweb="tab-list"] {
179
+ justify-content: center; /* Center the tabs themselves */
180
+ gap: 20px; /* Space between tabs */
181
+ margin-bottom: 2rem;
182
+ }
183
+ .stTabs [data-baseweb="tab-list"] button {
184
+ background-color: transparent;
185
+ border: none;
186
+ padding: 10px 20px;
187
+ font-size: 1.2em;
188
+ font-weight: 600;
189
+ color: #888888; /* Grey for inactive tabs */
190
+ border-bottom: 3px solid transparent;
191
+ transition: color 0.3s, border-bottom 0.3s;
192
+ }
193
+ .stTabs [data-baseweb="tab-list"] button:hover {
194
+ color: #7289da;
195
+ border-bottom: 3px solid #b0c4de; /* Lighter blue on hover */
196
+ }
197
+ .stTabs [data-baseweb="tab-list"] button[aria-selected="true"] {
198
+ color: #7289da; /* DilBot's primary color for active tab */
199
+ border-bottom: 3px solid #7289da; /* Stronger accent for active tab */
200
+ }
201
+
202
+ /* Input Fields */
203
  .stTextInput>label {
204
  font-weight: 600;
205
+ color: #555555;
206
+ text-align: left; /* Align labels to the left */
207
+ display: block; /* Make label a block element to control margin */
208
+ margin-bottom: 0.5rem;
209
+ padding-left: 5px; /* Small indent for label */
210
  }
211
+ .stTextInput>div>div>input {
212
+ border-radius: 10px; /* More rounded */
213
+ border: 1px solid #ced4da; /* Light grey border */
214
+ padding: 12px 15px; /* Increased padding */
215
+ font-size: 1.05em;
216
+ color: #333333;
217
+ box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); /* Subtle inner shadow */
218
+ transition: border-color 0.3s ease, box-shadow 0.3s ease;
219
+ }
220
+ .stTextInput>div>div>input:focus {
221
+ border-color: #7289da; /* Highlight on focus */
222
+ box-shadow: 0 0 0 0.2rem rgba(114, 137, 218, 0.25); /* Glow effect on focus */
223
+ outline: none;
224
+ }
225
+
226
+ /* Buttons */
227
  .stButton>button {
228
+ background-color: #7289da; /* DilBot's primary blue/purple */
229
  color: white;
 
230
  border: none;
231
+ border-radius: 10px; /* More rounded */
232
+ padding: 12px 25px; /* Larger padding */
233
+ font-size: 1.1em; /* Larger text */
234
  font-weight: bold;
235
+ transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
236
+ box-shadow: 0 5px 15px rgba(0,0,0,0.15); /* More prominent shadow */
237
+ cursor: pointer;
238
+ width: 100%; /* Make buttons full width */
239
+ margin-top: 1.5rem; /* Space above buttons */
240
  }
241
  .stButton>button:hover {
242
+ background-color: #5b6fb8; /* Darker shade on hover */
243
+ transform: translateY(-3px); /* More pronounced lift effect */
244
+ box-shadow: 0 8px 20px rgba(0,0,0,0.2);
245
+ }
246
+ .stButton>button:active {
247
+ background-color: #4a5a90;
248
+ transform: translateY(0);
249
+ box-shadow: 0 3px 10px rgba(0,0,0,0.1);
250
+ }
251
+
252
+ /* Alerts (Success, Error, Warning) */
253
+ [data-testid="stAlert"] {
254
+ border-radius: 8px;
255
+ padding: 15px 20px;
256
+ margin-bottom: 1.5rem;
257
+ font-size: 1em;
258
+ line-height: 1.5;
259
+ text-align: left; /* Align alert text to left */
260
+ }
261
+ /* Specific styles for each type - copied from previous example, ensuring consistency */
262
+ [data-testid="stAlert"] .streamlit-warning {
263
+ background-color: #fff3cd; color: #664d03; border-left: 5px solid #ffc107;
264
+ }
265
+ [data-testid="stAlert"] .streamlit-success {
266
+ background-color: #d1e7dd; color: #0f5132; border-left: 5px solid #198754;
267
+ }
268
+ [data-testid="stAlert"] .streamlit-error {
269
+ background-color: #f8d7da; color: #842029; border-left: 5px solid #dc3545;
270
+ }
271
+ [data-testid="stAlert"] .streamlit-info {
272
+ background-color: #cfe2ff; color: #055160; border-left: 5px solid #0dcaf0;
273
+ }
274
+
275
+ /* Small hack to adjust the spacing around form elements within tabs */
276
+ .stTabs [data-baseweb="tab-panel"] > div > div {
277
+ padding: 0 20px; /* Add horizontal padding inside tabs */
278
  }
279
  </style>
280
  """, unsafe_allow_html=True)
281
+ # --- END UPDATED CUSTOM CSS ---
282
+
283
+ # Using columns for the main title and welcome message to potentially add an image later
284
+ st.image("https://i.ibb.co/L5Qx81j/dilbot-logo.png", width=100) # Placeholder for a small logo
285
+ st.title("DilBot") # Just the name, 'Emotional AI Companion' can be the subtitle
286
+ st.markdown("<h3 style='text-align: center; color: #666666;'>Your Intelligent Emotional Companion</h3>", unsafe_allow_html=True) # Tagline as subtitle
287
+
288
+ st.markdown("---") # Visual separator
289
+
290
+ # Main content of the auth page, now inside a more visually contained area
291
  tab1, tab2 = st.tabs(["Login", "Sign Up"])
292
+
293
  with tab1:
294
  st.subheader("Login to Your Account")
295
+ login_username = st.text_input("Username", key="login_user", placeholder="Enter your username") # Added placeholder
296
+ login_password = st.text_input("Password", type="password", key="login_pass", placeholder="Enter your password") # Added placeholder
297
+
298
+ # Used st.container for the button to control its width if needed, or simply rely on CSS 'width: 100%'
299
+ if st.button("Login", key="login_btn", use_container_width=True):
300
  if login_username and login_password:
301
  success, message, is_admin = login(login_username, login_password)
302
  if success:
 
309
  st.error(message)
310
  else:
311
  st.warning("Please fill in all fields")
312
+
313
  with tab2:
314
  st.subheader("Create New Account")
315
+ signup_username = st.text_input("Choose Username", key="signup_user", placeholder="Choose a unique username")
316
+ signup_email = st.text_input("Email Address", key="signup_email", placeholder="Enter your email address")
317
+ signup_password = st.text_input("Choose Password", type="password", key="signup_pass", placeholder="At least 6 characters")
318
+ signup_confirm = st.text_input("Confirm Password", type="password", key="signup_confirm", placeholder="Re-enter your password")
319
+
320
+ if st.button("Create Account", key="signup_btn", use_container_width=True):
321
  if all([signup_username, signup_email, signup_password, signup_confirm]):
322
  if signup_password != signup_confirm:
323
  st.error("Passwords don't match!")
 
333
  else:
334
  st.warning("Please fill in all fields")
335
 
336
+ st.markdown("<br><br><small style='text-align: center; color: #888888;'>Powered by Streamlit & Groq</small>", unsafe_allow_html=True)
337
+
338
  # Main app functions
339
  def build_user_vectorstore(username, quotes):
340
  """Build and save user-specific vectorstore"""