Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -127,14 +127,14 @@ def detect_emotion(text):
|
|
| 127 |
|
| 128 |
# Authentication UI
|
| 129 |
def show_auth_page():
|
| 130 |
-
st.set_page_config(page_title="DilBot - Login", page_icon="🧠", layout="centered")
|
| 131 |
|
| 132 |
-
# ---
|
| 133 |
st.markdown("""
|
| 134 |
<style>
|
| 135 |
/* Overall App Background & Font */
|
| 136 |
.stApp {
|
| 137 |
-
background
|
| 138 |
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; /* Modern, clean font */
|
| 139 |
color: #333333; /* Default text color */
|
| 140 |
}
|
|
@@ -146,57 +146,68 @@ def show_auth_page():
|
|
| 146 |
.main .block-container {
|
| 147 |
max-width: 500px; /* Limit width for better aesthetics */
|
| 148 |
margin: auto; /* Center the container */
|
| 149 |
-
padding: 3rem
|
| 150 |
background-color: #ffffff; /* White background for the form card */
|
| 151 |
-
border-radius:
|
| 152 |
-
box-shadow: 0
|
| 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:
|
| 160 |
-
font-weight:
|
| 161 |
-
margin-bottom: 0.
|
|
|
|
| 162 |
}
|
| 163 |
-
.
|
| 164 |
-
color: #
|
| 165 |
-
font-size: 1.
|
| 166 |
-
margin-
|
|
|
|
|
|
|
| 167 |
}
|
| 168 |
h2 { /* Subheaders for Login/Sign Up tabs */
|
| 169 |
color: #4A4A4A;
|
| 170 |
-
font-size: 1.
|
| 171 |
-
font-weight:
|
| 172 |
margin-top: 1.5rem;
|
| 173 |
-
margin-bottom: 1.
|
| 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:
|
| 181 |
-
margin-bottom:
|
| 182 |
}
|
| 183 |
.stTabs [data-baseweb="tab-list"] button {
|
| 184 |
background-color: transparent;
|
| 185 |
border: none;
|
| 186 |
-
padding:
|
| 187 |
-
font-size: 1.
|
| 188 |
-
font-weight:
|
| 189 |
-
color: #
|
| 190 |
-
border-bottom:
|
| 191 |
transition: color 0.3s, border-bottom 0.3s;
|
| 192 |
}
|
| 193 |
.stTabs [data-baseweb="tab-list"] button:hover {
|
| 194 |
color: #7289da;
|
| 195 |
-
border-bottom:
|
| 196 |
}
|
| 197 |
.stTabs [data-baseweb="tab-list"] button[aria-selected="true"] {
|
| 198 |
color: #7289da; /* DilBot's primary color for active tab */
|
| 199 |
-
border-bottom:
|
| 200 |
}
|
| 201 |
|
| 202 |
/* Input Fields */
|
|
@@ -205,21 +216,22 @@ def show_auth_page():
|
|
| 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.
|
| 209 |
padding-left: 5px; /* Small indent for label */
|
| 210 |
}
|
| 211 |
.stTextInput>div>div>input {
|
| 212 |
-
border-radius:
|
| 213 |
-
border: 1px solid #
|
| 214 |
-
padding:
|
| 215 |
-
font-size: 1.
|
| 216 |
color: #333333;
|
| 217 |
-
|
|
|
|
| 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.
|
| 223 |
outline: none;
|
| 224 |
}
|
| 225 |
|
|
@@ -228,74 +240,92 @@ def show_auth_page():
|
|
| 228 |
background-color: #7289da; /* DilBot's primary blue/purple */
|
| 229 |
color: white;
|
| 230 |
border: none;
|
| 231 |
-
border-radius:
|
| 232 |
-
padding:
|
| 233 |
-
font-size: 1.
|
| 234 |
font-weight: bold;
|
| 235 |
transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
|
| 236 |
-
box-shadow: 0
|
| 237 |
cursor: pointer;
|
| 238 |
width: 100%; /* Make buttons full width */
|
| 239 |
-
margin-top:
|
|
|
|
| 240 |
}
|
| 241 |
.stButton>button:hover {
|
| 242 |
background-color: #5b6fb8; /* Darker shade on hover */
|
| 243 |
-
transform: translateY(-
|
| 244 |
-
box-shadow: 0
|
| 245 |
}
|
| 246 |
.stButton>button:active {
|
| 247 |
background-color: #4a5a90;
|
| 248 |
transform: translateY(0);
|
| 249 |
-
box-shadow: 0
|
| 250 |
}
|
| 251 |
|
| 252 |
-
/* Alerts (Success, Error, Warning) */
|
| 253 |
[data-testid="stAlert"] {
|
| 254 |
-
border-radius:
|
| 255 |
-
padding:
|
| 256 |
-
margin-bottom: 1.
|
| 257 |
-
font-size:
|
| 258 |
-
line-height: 1.
|
| 259 |
-
text-align: left;
|
|
|
|
| 260 |
}
|
| 261 |
-
/* Specific styles for each type
|
| 262 |
[data-testid="stAlert"] .streamlit-warning {
|
| 263 |
-
background-color: #
|
| 264 |
}
|
| 265 |
[data-testid="stAlert"] .streamlit-success {
|
| 266 |
-
background-color: #
|
| 267 |
}
|
| 268 |
[data-testid="stAlert"] .streamlit-error {
|
| 269 |
-
background-color: #
|
| 270 |
}
|
| 271 |
[data-testid="stAlert"] .streamlit-info {
|
| 272 |
-
background-color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 278 |
}
|
| 279 |
</style>
|
| 280 |
""", unsafe_allow_html=True)
|
| 281 |
-
# --- END
|
| 282 |
|
| 283 |
-
#
|
| 284 |
-
st.image
|
| 285 |
-
st.title("DilBot") # Just the name
|
| 286 |
-
st.markdown("<
|
| 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 |
-
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
|
@@ -312,10 +342,26 @@ def show_auth_page():
|
|
| 312 |
|
| 313 |
with tab2:
|
| 314 |
st.subheader("Create New Account")
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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]):
|
|
@@ -333,8 +379,7 @@ def show_auth_page():
|
|
| 333 |
else:
|
| 334 |
st.warning("Please fill in all fields")
|
| 335 |
|
| 336 |
-
st.markdown("<
|
| 337 |
-
|
| 338 |
# Main app functions
|
| 339 |
def build_user_vectorstore(username, quotes):
|
| 340 |
"""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")
|
| 131 |
|
| 132 |
+
# --- FURTHER ENHANCED CUSTOM CSS FOR THE AUTH PAGE ---
|
| 133 |
st.markdown("""
|
| 134 |
<style>
|
| 135 |
/* Overall App Background & Font */
|
| 136 |
.stApp {
|
| 137 |
+
background: linear-gradient(to right bottom, #f0f2f6, #e0e6ef); /* Subtle gradient background */
|
| 138 |
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; /* Modern, clean font */
|
| 139 |
color: #333333; /* Default text color */
|
| 140 |
}
|
|
|
|
| 146 |
.main .block-container {
|
| 147 |
max-width: 500px; /* Limit width for better aesthetics */
|
| 148 |
margin: auto; /* Center the container */
|
| 149 |
+
padding: 3rem 2.5rem; /* Increased padding top/bottom and sides */
|
| 150 |
background-color: #ffffff; /* White background for the form card */
|
| 151 |
+
border-radius: 20px; /* Even softer rounded corners */
|
| 152 |
+
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15); /* Deeper, softer shadow for card effect */
|
| 153 |
text-align: center; /* Center content within the card */
|
| 154 |
+
animation: fadeIn 0.8s ease-out; /* Add a subtle fade-in animation */
|
| 155 |
}
|
| 156 |
|
| 157 |
+
/* Keyframe for fade-in animation */
|
| 158 |
+
@keyframes fadeIn {
|
| 159 |
+
from { opacity: 0; transform: translateY(20px); }
|
| 160 |
+
to { opacity: 1; transform: translateY(0); }
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
/* Titles and Subheaders */
|
| 165 |
h1 {
|
| 166 |
color: #7289da; /* DilBot's primary color */
|
| 167 |
+
font-size: 3em; /* Larger title */
|
| 168 |
+
font-weight: 800; /* Bolder */
|
| 169 |
+
margin-bottom: 0.2rem; /* Less space to tagline */
|
| 170 |
+
letter-spacing: -0.5px; /* Slight letter spacing for visual appeal */
|
| 171 |
}
|
| 172 |
+
.tagline { /* Custom class for the tagline */
|
| 173 |
+
color: #6a7c96; /* Softer blue-grey for the tagline */
|
| 174 |
+
font-size: 1.2em;
|
| 175 |
+
margin-top: 0; /* Align closely with title */
|
| 176 |
+
margin-bottom: 2.5rem; /* More space to tabs */
|
| 177 |
+
font-weight: 500;
|
| 178 |
}
|
| 179 |
h2 { /* Subheaders for Login/Sign Up tabs */
|
| 180 |
color: #4A4A4A;
|
| 181 |
+
font-size: 1.8em; /* Slightly larger */
|
| 182 |
+
font-weight: 700; /* Bolder */
|
| 183 |
margin-top: 1.5rem;
|
| 184 |
+
margin-bottom: 1.8rem; /* More space below subheader */
|
| 185 |
text-align: center;
|
| 186 |
}
|
| 187 |
|
| 188 |
/* Tabs Styling */
|
| 189 |
.stTabs [data-baseweb="tab-list"] {
|
| 190 |
justify-content: center; /* Center the tabs themselves */
|
| 191 |
+
gap: 25px; /* More space between tabs */
|
| 192 |
+
margin-bottom: 2.5rem; /* More space below tabs */
|
| 193 |
}
|
| 194 |
.stTabs [data-baseweb="tab-list"] button {
|
| 195 |
background-color: transparent;
|
| 196 |
border: none;
|
| 197 |
+
padding: 12px 25px; /* Increased padding for tabs */
|
| 198 |
+
font-size: 1.3em; /* Larger tab text */
|
| 199 |
+
font-weight: 700; /* Bolder */
|
| 200 |
+
color: #a0a0a0; /* Lighter grey for inactive tabs */
|
| 201 |
+
border-bottom: 4px solid transparent; /* Thicker underline */
|
| 202 |
transition: color 0.3s, border-bottom 0.3s;
|
| 203 |
}
|
| 204 |
.stTabs [data-baseweb="tab-list"] button:hover {
|
| 205 |
color: #7289da;
|
| 206 |
+
border-bottom: 4px solid #b0c4de; /* Lighter blue on hover */
|
| 207 |
}
|
| 208 |
.stTabs [data-baseweb="tab-list"] button[aria-selected="true"] {
|
| 209 |
color: #7289da; /* DilBot's primary color for active tab */
|
| 210 |
+
border-bottom: 4px solid #7289da; /* Stronger accent for active tab */
|
| 211 |
}
|
| 212 |
|
| 213 |
/* Input Fields */
|
|
|
|
| 216 |
color: #555555;
|
| 217 |
text-align: left; /* Align labels to the left */
|
| 218 |
display: block; /* Make label a block element to control margin */
|
| 219 |
+
margin-bottom: 0.6rem; /* More space below label */
|
| 220 |
padding-left: 5px; /* Small indent for label */
|
| 221 |
}
|
| 222 |
.stTextInput>div>div>input {
|
| 223 |
+
border-radius: 12px; /* Even more rounded */
|
| 224 |
+
border: 1px solid #e0e0e0; /* Softer border */
|
| 225 |
+
padding: 14px 18px; /* Even more padding */
|
| 226 |
+
font-size: 1.1em; /* Slightly larger font in input */
|
| 227 |
color: #333333;
|
| 228 |
+
background-color: #fcfcfc; /* Slightly off-white background */
|
| 229 |
+
box-shadow: inset 0 2px 5px rgba(0,0,0,0.03); /* More subtle inner shadow */
|
| 230 |
transition: border-color 0.3s ease, box-shadow 0.3s ease;
|
| 231 |
}
|
| 232 |
.stTextInput>div>div>input:focus {
|
| 233 |
border-color: #7289da; /* Highlight on focus */
|
| 234 |
+
box-shadow: 0 0 0 0.25rem rgba(114, 137, 218, 0.3); /* Stronger glow effect on focus */
|
| 235 |
outline: none;
|
| 236 |
}
|
| 237 |
|
|
|
|
| 240 |
background-color: #7289da; /* DilBot's primary blue/purple */
|
| 241 |
color: white;
|
| 242 |
border: none;
|
| 243 |
+
border-radius: 12px; /* More rounded */
|
| 244 |
+
padding: 14px 28px; /* Larger padding */
|
| 245 |
+
font-size: 1.2em; /* Larger text */
|
| 246 |
font-weight: bold;
|
| 247 |
transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
|
| 248 |
+
box-shadow: 0 8px 25px rgba(0,0,0,0.2); /* More prominent, softer shadow */
|
| 249 |
cursor: pointer;
|
| 250 |
width: 100%; /* Make buttons full width */
|
| 251 |
+
margin-top: 2rem; /* More space above buttons */
|
| 252 |
+
letter-spacing: 0.5px; /* Slight letter spacing */
|
| 253 |
}
|
| 254 |
.stButton>button:hover {
|
| 255 |
background-color: #5b6fb8; /* Darker shade on hover */
|
| 256 |
+
transform: translateY(-4px); /* More pronounced lift effect */
|
| 257 |
+
box-shadow: 0 12px 30px rgba(0,0,0,0.25); /* Stronger shadow on hover */
|
| 258 |
}
|
| 259 |
.stButton>button:active {
|
| 260 |
background-color: #4a5a90;
|
| 261 |
transform: translateY(0);
|
| 262 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.15);
|
| 263 |
}
|
| 264 |
|
| 265 |
+
/* Alerts (Success, Error, Warning, Info) - more refined */
|
| 266 |
[data-testid="stAlert"] {
|
| 267 |
+
border-radius: 10px;
|
| 268 |
+
padding: 18px 25px; /* More padding */
|
| 269 |
+
margin-bottom: 1.8rem; /* More space below */
|
| 270 |
+
font-size: 1.05em; /* Slightly larger text */
|
| 271 |
+
line-height: 1.6;
|
| 272 |
+
text-align: left;
|
| 273 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.05); /* Subtle shadow for alerts */
|
| 274 |
}
|
| 275 |
+
/* Specific styles for each type with slightly richer colors */
|
| 276 |
[data-testid="stAlert"] .streamlit-warning {
|
| 277 |
+
background-color: #fef7e0; color: #7a5f00; border-left: 6px solid #ffcc00;
|
| 278 |
}
|
| 279 |
[data-testid="stAlert"] .streamlit-success {
|
| 280 |
+
background-color: #e6ffe6; color: #0a6b0a; border-left: 6px solid #4CAF50;
|
| 281 |
}
|
| 282 |
[data-testid="stAlert"] .streamlit-error {
|
| 283 |
+
background-color: #ffe6e6; color: #8c0a0a; border-left: 6px solid #e74c3c;
|
| 284 |
}
|
| 285 |
[data-testid="stAlert"] .streamlit-info {
|
| 286 |
+
background-color: #e6f7ff; color: #0a4d6e; border-left: 6px solid #3498db;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
/* Footer/Attribution */
|
| 290 |
+
.footer {
|
| 291 |
+
color: #a0a0a0;
|
| 292 |
+
font-size: 0.8em;
|
| 293 |
+
margin-top: 3rem; /* More space from form */
|
| 294 |
+
display: block;
|
| 295 |
+
text-align: center;
|
| 296 |
+
letter-spacing: 0.2px;
|
| 297 |
}
|
| 298 |
|
| 299 |
/* Small hack to adjust the spacing around form elements within tabs */
|
| 300 |
.stTabs [data-baseweb="tab-panel"] > div > div {
|
| 301 |
+
padding: 0 10px; /* Slight horizontal padding inside tabs */
|
| 302 |
}
|
| 303 |
</style>
|
| 304 |
""", unsafe_allow_html=True)
|
| 305 |
+
# --- END FURTHER ENHANCED CUSTOM CSS ---
|
| 306 |
|
| 307 |
+
# Visual Enhancements using Streamlit API
|
| 308 |
+
# Removed st.image as it was causing "Image not found"
|
| 309 |
+
st.title("DilBot") # Just the name
|
| 310 |
+
st.markdown("<p class='tagline'>Your Intelligent Emotional Companion</p>", unsafe_allow_html=True) # Tagline as subtitle
|
| 311 |
|
| 312 |
st.markdown("---") # Visual separator
|
| 313 |
|
|
|
|
| 314 |
tab1, tab2 = st.tabs(["Login", "Sign Up"])
|
| 315 |
|
| 316 |
with tab1:
|
| 317 |
st.subheader("Login to Your Account")
|
| 318 |
+
# Added an icon for username/password fields for visual cue
|
| 319 |
+
login_username = st.text_input("Username", key="login_user", placeholder="Enter your username",
|
| 320 |
+
label_visibility="collapsed") # Hide default label, use markdown label
|
| 321 |
+
st.markdown("<p style='text-align: left; color: #555555; font-weight: 600; margin-bottom: 0.6rem; padding-left: 5px;'>Username</p>", unsafe_allow_html=True)
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
login_password = st.text_input("Password", type="password", key="login_pass", placeholder="Enter your password",
|
| 325 |
+
label_visibility="collapsed")
|
| 326 |
+
st.markdown("<p style='text-align: left; color: #555555; font-weight: 600; margin-bottom: 0.6rem; padding-left: 5px;'>Password</p>", unsafe_allow_html=True)
|
| 327 |
+
|
| 328 |
|
|
|
|
| 329 |
if st.button("Login", key="login_btn", use_container_width=True):
|
| 330 |
if login_username and login_password:
|
| 331 |
success, message, is_admin = login(login_username, login_password)
|
|
|
|
| 342 |
|
| 343 |
with tab2:
|
| 344 |
st.subheader("Create New Account")
|
| 345 |
+
|
| 346 |
+
signup_username = st.text_input("Choose Username", key="signup_user", placeholder="Choose a unique username",
|
| 347 |
+
label_visibility="collapsed")
|
| 348 |
+
st.markdown("<p style='text-align: left; color: #555555; font-weight: 600; margin-bottom: 0.6rem; padding-left: 5px;'>Choose Username</p>", unsafe_allow_html=True)
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
signup_email = st.text_input("Email Address", key="signup_email", placeholder="Enter your email address",
|
| 352 |
+
label_visibility="collapsed")
|
| 353 |
+
st.markdown("<p style='text-align: left; color: #555555; font-weight: 600; margin-bottom: 0.6rem; padding-left: 5px;'>Email Address</p>", unsafe_allow_html=True)
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
signup_password = st.text_input("Choose Password", type="password", key="signup_pass", placeholder="At least 6 characters",
|
| 357 |
+
label_visibility="collapsed")
|
| 358 |
+
st.markdown("<p style='text-align: left; color: #555555; font-weight: 600; margin-bottom: 0.6rem; padding-left: 5px;'>Choose Password</p>", unsafe_allow_html=True)
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
signup_confirm = st.text_input("Confirm Password", type="password", key="signup_confirm", placeholder="Re-enter your password",
|
| 362 |
+
label_visibility="collapsed")
|
| 363 |
+
st.markdown("<p style='text-align: left; color: #555555; font-weight: 600; margin-bottom: 0.6rem; padding-left: 5px;'>Confirm Password</p>", unsafe_allow_html=True)
|
| 364 |
+
|
| 365 |
|
| 366 |
if st.button("Create Account", key="signup_btn", use_container_width=True):
|
| 367 |
if all([signup_username, signup_email, signup_password, signup_confirm]):
|
|
|
|
| 379 |
else:
|
| 380 |
st.warning("Please fill in all fields")
|
| 381 |
|
| 382 |
+
st.markdown("<p class='footer'>Built with ❤️ by CSG Hackathon Team | Powered by Streamlit & Groq</p>", unsafe_allow_html=True)
|
|
|
|
| 383 |
# Main app functions
|
| 384 |
def build_user_vectorstore(username, quotes):
|
| 385 |
"""Build and save user-specific vectorstore"""
|