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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
from groq import Groq
|
| 4 |
+
from streamlit.components.v1 import html
|
| 5 |
+
import random
|
| 6 |
+
|
| 7 |
+
# Set up page configuration
|
| 8 |
+
st.set_page_config(page_title="EduNexus π", page_icon="π", layout="wide")
|
| 9 |
+
|
| 10 |
+
api_key = st.secrets["GROQ_API_KEY"]
|
| 11 |
+
client = Groq(api_key=api_key)
|
| 12 |
+
|
| 13 |
+
# Define the LLaMA model to be used
|
| 14 |
+
MODEL_NAME = "llama3-8b-8192" # Replace with your actual model name
|
| 15 |
+
|
| 16 |
+
# Function to call Groq API
|
| 17 |
+
def call_groq_api(prompt):
|
| 18 |
+
try:
|
| 19 |
+
chat_completion = client.chat.completions.create(
|
| 20 |
+
messages=[{"role": "user", "content": prompt}],
|
| 21 |
+
model=MODEL_NAME
|
| 22 |
+
)
|
| 23 |
+
return chat_completion.choices[0].message.content
|
| 24 |
+
except Exception as e:
|
| 25 |
+
return f"Error: {str(e)}"
|
| 26 |
+
|
| 27 |
+
# Define functions for each tool with few-shot examples (unchanged)
|
| 28 |
+
def personalized_learning_assistant(topic):
|
| 29 |
+
# ... (unchanged)
|
| 30 |
+
|
| 31 |
+
def ai_coding_mentor(code_snippet):
|
| 32 |
+
# ... (unchanged)
|
| 33 |
+
|
| 34 |
+
def smart_document_summarizer(document_text):
|
| 35 |
+
# ... (unchanged)
|
| 36 |
+
|
| 37 |
+
def interactive_study_planner(exam_schedule):
|
| 38 |
+
# ... (unchanged)
|
| 39 |
+
|
| 40 |
+
def real_time_qa_support(question):
|
| 41 |
+
# ... (unchanged)
|
| 42 |
+
|
| 43 |
+
def mental_health_check_in(feelings):
|
| 44 |
+
# ... (unchanged)
|
| 45 |
+
|
| 46 |
+
# Initialize session state if not already set
|
| 47 |
+
if 'responses' not in st.session_state:
|
| 48 |
+
st.session_state['responses'] = {
|
| 49 |
+
"personalized_learning_assistant": "",
|
| 50 |
+
"ai_coding_mentor": "",
|
| 51 |
+
"smart_document_summarizer": "",
|
| 52 |
+
"interactive_study_planner": "",
|
| 53 |
+
"real_time_qa_support": "",
|
| 54 |
+
"mental_health_check_in": ""
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
# Function to clear session state values
|
| 58 |
+
def clear_session_state():
|
| 59 |
+
for key in st.session_state.keys():
|
| 60 |
+
if key.startswith('responses'):
|
| 61 |
+
st.session_state[key] = ""
|
| 62 |
+
if key in ['personalized_learning_assistant', 'ai_coding_mentor', 'smart_document_summarizer', 'interactive_study_planner', 'real_time_qa_support', 'mental_health_check_in']:
|
| 63 |
+
st.session_state[key] = ""
|
| 64 |
+
|
| 65 |
+
# Function to load custom CSS
|
| 66 |
+
def load_css():
|
| 67 |
+
return """
|
| 68 |
+
<style>
|
| 69 |
+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
|
| 70 |
+
|
| 71 |
+
body {
|
| 72 |
+
font-family: 'Poppins', sans-serif;
|
| 73 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 74 |
+
color: #ffffff;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
.stApp {
|
| 78 |
+
background-color: rgba(255, 255, 255, 0.1);
|
| 79 |
+
backdrop-filter: blur(10px);
|
| 80 |
+
border-radius: 20px;
|
| 81 |
+
padding: 2rem;
|
| 82 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.main-title {
|
| 86 |
+
font-size: 3.5rem;
|
| 87 |
+
font-weight: 700;
|
| 88 |
+
text-align: center;
|
| 89 |
+
margin-bottom: 2rem;
|
| 90 |
+
color: #ffffff;
|
| 91 |
+
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.stButton > button {
|
| 95 |
+
background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
|
| 96 |
+
color: white;
|
| 97 |
+
border: none;
|
| 98 |
+
border-radius: 30px;
|
| 99 |
+
padding: 0.6rem 1.2rem;
|
| 100 |
+
font-weight: 600;
|
| 101 |
+
transition: all 0.3s ease;
|
| 102 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.stButton > button:hover {
|
| 106 |
+
transform: translateY(-3px);
|
| 107 |
+
box-shadow: 0 6px 8px rgba(0,0,0,0.15);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.stTextInput > div > div > input,
|
| 111 |
+
.stTextArea > div > div > textarea {
|
| 112 |
+
background-color: rgba(255, 255, 255, 0.2);
|
| 113 |
+
border: 2px solid rgba(255, 255, 255, 0.5);
|
| 114 |
+
border-radius: 10px;
|
| 115 |
+
color: #ffffff;
|
| 116 |
+
font-size: 1rem;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.stRadio > div {
|
| 120 |
+
background-color: rgba(255, 255, 255, 0.2);
|
| 121 |
+
border-radius: 10px;
|
| 122 |
+
padding: 1rem;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.stRadio > div > label {
|
| 126 |
+
color: #ffffff !important;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.footer {
|
| 130 |
+
text-align: center;
|
| 131 |
+
padding: 1rem;
|
| 132 |
+
background-color: rgba(255, 255, 255, 0.1);
|
| 133 |
+
border-radius: 10px;
|
| 134 |
+
margin-top: 2rem;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.footer a {
|
| 138 |
+
color: #ffffff;
|
| 139 |
+
text-decoration: none;
|
| 140 |
+
margin: 0 1rem;
|
| 141 |
+
font-weight: 500;
|
| 142 |
+
transition: all 0.3s ease;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
.footer a:hover {
|
| 146 |
+
color: #4ECDC4;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
/* Animated background */
|
| 150 |
+
@keyframes gradientBG {
|
| 151 |
+
0% {background-position: 0% 50%;}
|
| 152 |
+
50% {background-position: 100% 50%;}
|
| 153 |
+
100% {background-position: 0% 50%;}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
body::before {
|
| 157 |
+
content: "";
|
| 158 |
+
position: fixed;
|
| 159 |
+
top: 0;
|
| 160 |
+
left: 0;
|
| 161 |
+
width: 100%;
|
| 162 |
+
height: 100%;
|
| 163 |
+
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
|
| 164 |
+
background-size: 400% 400%;
|
| 165 |
+
animation: gradientBG 15s ease infinite;
|
| 166 |
+
z-index: -1;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/* 3D Card Effect */
|
| 170 |
+
.tool-card {
|
| 171 |
+
background-color: rgba(255, 255, 255, 0.1);
|
| 172 |
+
border-radius: 20px;
|
| 173 |
+
padding: 1.5rem;
|
| 174 |
+
margin-bottom: 1rem;
|
| 175 |
+
transition: all 0.3s ease;
|
| 176 |
+
transform: perspective(1000px) rotateX(0deg) rotateY(0deg);
|
| 177 |
+
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.tool-card:hover {
|
| 181 |
+
transform: perspective(1000px) rotateX(10deg) rotateY(10deg);
|
| 182 |
+
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/* Emoji styles */
|
| 186 |
+
.emoji {
|
| 187 |
+
font-size: 2rem;
|
| 188 |
+
margin-right: 0.5rem;
|
| 189 |
+
}
|
| 190 |
+
</style>
|
| 191 |
+
"""
|
| 192 |
+
|
| 193 |
+
# Inject custom CSS
|
| 194 |
+
st.markdown(load_css(), unsafe_allow_html=True)
|
| 195 |
+
|
| 196 |
+
# Main content area with 3D-inspired title
|
| 197 |
+
st.markdown("<h1 class='main-title'>π Welcome to EduNexus</h1>", unsafe_allow_html=True)
|
| 198 |
+
st.markdown("<p style='text-align: center; font-size: 1.2rem; margin-bottom: 2rem;'>Your AI-powered learning companion for the 21st century</p>", unsafe_allow_html=True)
|
| 199 |
+
|
| 200 |
+
# Sidebar with navigation options
|
| 201 |
+
st.sidebar.markdown("<h2 style='text-align: center;'>π§ EduNexus Tools</h2>", unsafe_allow_html=True)
|
| 202 |
+
selected_task = st.sidebar.radio("Select a Tool", [
|
| 203 |
+
"π§βπ Personalized Learning Assistant",
|
| 204 |
+
"π€ AI Coding Mentor",
|
| 205 |
+
"π Smart Document Summarizer",
|
| 206 |
+
"π Interactive Study Planner",
|
| 207 |
+
"β Real-Time Q&A Support",
|
| 208 |
+
"π¬ Mental Health Check-In"
|
| 209 |
+
])
|
| 210 |
+
|
| 211 |
+
# Display the selected task based on user selection
|
| 212 |
+
st.markdown(f"<h2 class='tool-title'>{selected_task}</h2>", unsafe_allow_html=True)
|
| 213 |
+
|
| 214 |
+
if selected_task == "π§βπ Personalized Learning Assistant":
|
| 215 |
+
st.markdown("""
|
| 216 |
+
<div class='tool-card'>
|
| 217 |
+
<h3><span class='emoji'>π</span>Create Your Learning Journey</h3>
|
| 218 |
+
<p>Enter a topic you're interested in, and let our AI craft a personalized learning plan just for you!</p>
|
| 219 |
+
</div>
|
| 220 |
+
""", unsafe_allow_html=True)
|
| 221 |
+
topic = st.text_input("What would you like to learn about? π€")
|
| 222 |
+
col1, col2 = st.columns([1, 3])
|
| 223 |
+
with col1:
|
| 224 |
+
if st.button("π§Ή Clear"):
|
| 225 |
+
st.session_state['responses']["personalized_learning_assistant"] = ""
|
| 226 |
+
st.rerun()
|
| 227 |
+
with col2:
|
| 228 |
+
if st.button("π Generate Learning Plan"):
|
| 229 |
+
if topic:
|
| 230 |
+
with st.spinner("Crafting your personalized learning journey..."):
|
| 231 |
+
st.session_state['responses']["personalized_learning_assistant"] = personalized_learning_assistant(topic)
|
| 232 |
+
else:
|
| 233 |
+
st.session_state['responses']["personalized_learning_assistant"] = "Please enter a topic to get started on your learning adventure! π"
|
| 234 |
+
|
| 235 |
+
st.markdown("<div class='response-area'>", unsafe_allow_html=True)
|
| 236 |
+
st.markdown("### Your Personalized Learning Plan:")
|
| 237 |
+
st.markdown(st.session_state['responses']["personalized_learning_assistant"])
|
| 238 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 239 |
+
|
| 240 |
+
elif selected_task == "π€ AI Coding Mentor":
|
| 241 |
+
st.markdown("""
|
| 242 |
+
<div class='tool-card'>
|
| 243 |
+
<h3><span class='emoji'>π»</span>Get Expert Code Review</h3>
|
| 244 |
+
<p>Paste your code snippet below, and our AI mentor will provide insightful suggestions and improvements!</p>
|
| 245 |
+
</div>
|
| 246 |
+
""", unsafe_allow_html=True)
|
| 247 |
+
code_snippet = st.text_area("Paste your code here for review π¨βπ»")
|
| 248 |
+
col1, col2 = st.columns([1, 3])
|
| 249 |
+
with col1:
|
| 250 |
+
if st.button("π§Ή Clear"):
|
| 251 |
+
st.session_state['responses']["ai_coding_mentor"] = ""
|
| 252 |
+
st.rerun()
|
| 253 |
+
with col2:
|
| 254 |
+
if st.button("π Analyze Code"):
|
| 255 |
+
if code_snippet:
|
| 256 |
+
with st.spinner("Analyzing your code with AI precision..."):
|
| 257 |
+
st.session_state['responses']["ai_coding_mentor"] = ai_coding_mentor(code_snippet)
|
| 258 |
+
else:
|
| 259 |
+
st.session_state['responses']["ai_coding_mentor"] = "Please enter a code snippet for our AI to review and enhance! π₯οΈ"
|
| 260 |
+
|
| 261 |
+
st.markdown("<div class='response-area'>", unsafe_allow_html=True)
|
| 262 |
+
st.markdown("### AI Code Review Results:")
|
| 263 |
+
st.code(st.session_state['responses']["ai_coding_mentor"])
|
| 264 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 265 |
+
|
| 266 |
+
elif selected_task == "π Smart Document Summarizer":
|
| 267 |
+
st.markdown("""
|
| 268 |
+
<div class='tool-card'>
|
| 269 |
+
<h3><span class='emoji'>π</span>Summarize Any Document</h3>
|
| 270 |
+
<p>Paste your document text, and watch as our AI distills it into a concise, informative summary!</p>
|
| 271 |
+
</div>
|
| 272 |
+
""", unsafe_allow_html=True)
|
| 273 |
+
document_text = st.text_area("Paste your document text here π")
|
| 274 |
+
col1, col2 = st.columns([1, 3])
|
| 275 |
+
with col1:
|
| 276 |
+
if st.button("π§Ή Clear"):
|
| 277 |
+
st.session_state['responses']["smart_document_summarizer"] = ""
|
| 278 |
+
st.rerun()
|
| 279 |
+
with col2:
|
| 280 |
+
if st.button("π Summarize"):
|
| 281 |
+
if document_text:
|
| 282 |
+
with st.spinner("Condensing your document into a brilliant summary..."):
|
| 283 |
+
st.session_state['responses']["smart_document_summarizer"] = smart_document_summarizer(document_text)
|
| 284 |
+
else:
|
| 285 |
+
st.session_state['responses']["smart_document_summarizer"] = "Please paste a document for our AI to summarize! π"
|
| 286 |
+
|
| 287 |
+
st.markdown("<div class='response-area'>", unsafe_allow_html=True)
|
| 288 |
+
st.markdown("### Your Document Summary:")
|
| 289 |
+
st.markdown(st.session_state['responses']["smart_document_summarizer"])
|
| 290 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 291 |
+
|
| 292 |
+
elif selected_task == "π Interactive Study Planner":
|
| 293 |
+
st.markdown("""
|
| 294 |
+
<div class='tool-card'>
|
| 295 |
+
<h3><span class='emoji'>π
</span>Plan Your Study Schedule</h3>
|
| 296 |
+
<p>Input your exam dates and subjects, and let our AI create a tailored study plan to maximize your success!</p>
|
| 297 |
+
</div>
|
| 298 |
+
""", unsafe_allow_html=True)
|
| 299 |
+
exam_schedule = st.text_area("Enter your exam schedule (e.g., 'Math: May 15, Physics: May 20') π")
|
| 300 |
+
col1, col2 = st.columns([1, 3])
|
| 301 |
+
with col1:
|
| 302 |
+
if st.button("π§Ή Clear"):
|
| 303 |
+
st.session_state['responses']["interactive_study_planner"] = ""
|
| 304 |
+
st.rerun()
|
| 305 |
+
with col2:
|
| 306 |
+
if st.button("π― Create Study Plan"):
|
| 307 |
+
if exam_schedule:
|
| 308 |
+
with st.spinner("Crafting your personalized study strategy..."):
|
| 309 |
+
st.session_state['responses']["interactive_study_planner"] = interactive_study_planner(exam_schedule)
|
| 310 |
+
else:
|
| 311 |
+
st.session_state['responses']["interactive_study_planner"] = "Please enter your exam schedule to get a customized study plan! π"
|
| 312 |
+
|
| 313 |
+
st.markdown("<div class='response-area'>", unsafe_allow_html=True)
|
| 314 |
+
st.markdown("### Your Personalized Study Plan:")
|
| 315 |
+
st.markdown(st.session_state['responses']["interactive_study_planner"])
|
| 316 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 317 |
+
|
| 318 |
+
elif selected_task == "β Real-Time Q&A Support":
|
| 319 |
+
st.markdown("""
|
| 320 |
+
<div class='tool-card'>
|
| 321 |
+
<h3><span class='emoji'>π€</span>Ask Anything, Anytime</h3>
|
| 322 |
+
<p>Got a burning question? Our AI is ready to provide instant, accurate answers to fuel your curiosity!</p>
|
| 323 |
+
</div>
|
| 324 |
+
""", unsafe_allow_html=True)
|
| 325 |
+
question = st.text_input("What's your question? π§")
|
| 326 |
+
col1, col2 = st.columns([1, 3])
|
| 327 |
+
with col1:
|
| 328 |
+
if st.button("π§Ή Clear"):
|
| 329 |
+
st.session_state['responses']["real_time_qa_support"] = ""
|
| 330 |
+
st.rerun()
|
| 331 |
+
with col2:
|
| 332 |
+
if st.button("π‘ Get Answer"):
|
| 333 |
+
if question:
|
| 334 |
+
with st.spinner("Searching the depths of knowledge for your answer..."):
|
| 335 |
+
st.session_state['responses']["real_time_qa_support"] = real_time_qa_support(question)
|
| 336 |
+
else:
|
| 337 |
+
st.session_state['responses']["real_time_qa_support"] = "Please ask a question to unlock the wisdom of our AI! π"
|
| 338 |
+
|
| 339 |
+
st.markdown("<div class='response-area'>", unsafe_allow_html=True)
|
| 340 |
+
st.markdown("### Your Answer:")
|
| 341 |
+
st.markdown(st.session_state['responses']["real_time_qa_support"])
|
| 342 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 343 |
+
|
| 344 |
+
elif selected_task == "π¬ Mental Health Check-In":
|
| 345 |
+
st.markdown("""
|
| 346 |
+
<div class='tool-card'>
|
| 347 |
+
<h3><span class='emoji'>π</span>Your Emotional Wellness Companion</h3>
|
| 348 |
+
<p>Share how you're feeling, and let our AI provide supportive advice and resources for your mental well-being.</p>
|
| 349 |
+
</div>
|
| 350 |
+
""", unsafe_allow_html=True)
|
| 351 |
+
feelings = st.text_input("How are you feeling today? π")
|
| 352 |
+
col1, col2 = st.columns([1, 3])
|
| 353 |
+
with col1:
|
| 354 |
+
if st.button("π§Ή Clear"):
|
| 355 |
+
st.session_state['responses']["mental_health_check_in"] = ""
|
| 356 |
+
st.rerun()
|
| 357 |
+
with col2:
|
| 358 |
+
if st.button("π€ Get Support"):
|
| 359 |
+
if feelings:
|
| 360 |
+
with st.spinner("Analyzing your emotions with care and empathy..."):
|
| 361 |
+
st.session_state['responses']["mental_health_check_in"] = mental_health_check_in(feelings)
|
| 362 |
+
else:
|
| 363 |
+
st.session_state['responses']["mental_health_check_in"] = "Please share how you're feeling so we can offer personalized support. π"
|
| 364 |
+
|
| 365 |
+
st.markdown("<div class='response-area'>", unsafe_allow_html=True)
|
| 366 |
+
st.markdown("### Your Personalized Support:")
|
| 367 |
+
st.markdown(st.session_state['responses']["mental_health_check_in"])
|
| 368 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 369 |
+
|
| 370 |
+
# Animated background
|
| 371 |
+
st.markdown("""
|
| 372 |
+
<div class="stApp">
|
| 373 |
+
<div class="animated-bg"></div>
|
| 374 |
+
</div>
|
| 375 |
+
""", unsafe_allow_html=True)
|
| 376 |
+
|
| 377 |
+
# Footer with contact information
|
| 378 |
+
st.markdown("""
|
| 379 |
+
<div class="footer">
|
| 380 |
+
<a href="https://github.com/muhammadibrahim313" target="_blank"><i class="fab fa-github"></i> GitHub</a>
|
| 381 |
+
<a href="https://www.linkedin.com/in/muhammad-ibrahim-qasmi-9876a1297/" target="_blank"><i class="fab fa-linkedin"></i> LinkedIn</a>
|
| 382 |
+
<a href="https://github.com/Ahmad-Fakhar" target="_blank"><i class="fab fa-github"></i> Partner's GitHub</a>
|
| 383 |
+
<a href="https://www.linkedin.com/in/ahmad-fakhar-357742258/" target="_blank"><i class="fab fa-linkedin"></i> Partner's LinkedIn</a>
|
| 384 |
+
</div>
|
| 385 |
+
""", unsafe_allow_html=True)
|
| 386 |
+
|
| 387 |
+
# Add some playful elements
|
| 388 |
+
st.balloons()
|
| 389 |
+
|
| 390 |
+
# Display a random inspirational quote
|
| 391 |
+
quotes = [
|
| 392 |
+
"The capacity to learn is a gift; the ability to learn is a skill; the willingness to learn is a choice. - Brian Herbert",
|
| 393 |
+
"Education is the passport to the future, for tomorrow belongs to those who prepare for it today. - Malcolm X",
|
| 394 |
+
"The beautiful thing about learning is that nobody can take it away from you. - B.B. King",
|
| 395 |
+
"The more that you read, the more things you will know. The more that you learn, the more places you'll go. - Dr. Seuss",
|
| 396 |
+
"Live as if you were to die tomorrow. Learn as if you were to live forever. - Mahatma Gandhi"
|
| 397 |
+
]
|
| 398 |
+
st.sidebar.markdown(f"### π‘ Quote of the Day\n\n*{random.choice(quotes)}*")
|
| 399 |
+
|
| 400 |
+
if __name__ == "__main__":
|
| 401 |
+
main()
|