File size: 4,317 Bytes
bffbf38 4265988 bffbf38 4265988 bffbf38 4265988 bffbf38 4265988 bffbf38 4265988 bffbf38 4265988 |
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
import os
import streamlit as st
from groq import Groq
# Set up the Groq client and API key
GROQ_API_KEY = "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"
os.environ["GROQ_API_KEY"] = GROQ_API_KEY
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
# Define the response fetching function
def get_study_plan(prompt):
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": prompt}],
model="llama3-8b-8192"
)
return chat_completion.choices[0].message.content
# Streamlit UI
st.set_page_config(page_title="Personalized Study Chatbot", layout="wide")
st.markdown(
"<h2 style='text-align: center; color: #4A90E2; font-size: 30px;'>Developed by <i>Muhammad Khaqan Nasir</i></h2>",
unsafe_allow_html=True
)
# LinkedIn icon and link
st.markdown(
"""
<h4 style='text-align: center; font-size: 20px;'>
<a href='https://www.linkedin.com/in/muhammad-khaqan-nasir/' style='color: #4A90E2;'>
<img src='https://upload.wikimedia.org/wikipedia/commons/8/81/LinkedIn_icon.svg' style='width: 20px; height: 20px; text-decoration:none; vertical-align: middle;' /> LinkedIn
</a>
</h4>
""",
unsafe_allow_html=True
)
st.title("π Personalized Study Plan Generator")
st.write("Quickly generate a tailored study plan with tips and resources to help you prepare efficiently!")
# Include Poppins font and increase font size globally, set content width to 100%
st.markdown(
"""
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');
/* Apply Poppins font and increase font size */
body {
font-family: 'Poppins', sans-serif;
font-size: 18px;
}
</style>
""", unsafe_allow_html=True
)
# Input fields for user details
study_goal = st.text_input("π― Study Goal (e.g., pass physics exam, learn programming basics):", placeholder="Your study objective")
total_days = st.number_input("π
Number of days to prepare:", min_value=1, max_value=365, step=1)
hours_per_day = st.number_input("β° Hours available per day:", min_value=1, max_value=24, step=1)
# Button to generate the study plan
if st.button("Generate My Study Plan"):
prompt = (
f"You are a personalized study assistant chatbot designed to help users prepare for exams and master subjects. "
f"The user has {total_days} days to prepare, dedicating {hours_per_day} hours per day. "
f"Their goal is: '{study_goal}'. Create a structured plan with practical tips, links to high-quality, free learning resources, "
f"and include the best YouTube channels if applicable."
"\nIf direct links are unavailable, provide names of resources. Add a summary, schedule, study tips, and 2β3 recommended resources (e.g., Khan Academy, Coursera) for free access.\n"
)
# Fetch response
response = get_study_plan(prompt)
# Display the response with enhanced styling
st.markdown("<h3 style='color: #4A90E2;'>Your Personalized Study Plan</h3>", unsafe_allow_html=True)
st.markdown(f"<div style='font-size: 18px; line-height: 1.6; color: #333;'>{response}</div>", unsafe_allow_html=True)
# Additional Resources Section
st.markdown("<h3 style='color: #4A90E2;'>π Recommended Learning Resources</h3>", unsafe_allow_html=True)
st.write("Here are some highly recommended resources for your study:")
st.markdown(
"""
- [Khan Academy](https://www.khanacademy.org) - Comprehensive courses on a variety of topics.
- [Coursera](https://www.coursera.org) - Free courses from top universities.
- [OpenStax](https://openstax.org/) - Free textbooks on many subjects.
- [YouTube](https://www.youtube.com) - Search for trusted channels like CrashCourse, 3Blue1Brown, or freeCodeCamp.
""", unsafe_allow_html=True
)
# Optional Additional UX Enhancements with expander section
with st.expander("π οΈ Additional Tips & Enhancements"):
st.write("1. **Set Clear Goals:** Break down your study goal into smaller, actionable tasks.")
st.write("2. **Daily Reflections:** Reflect on what you've learned to retain information better.")
st.write("3. **Mock Tests:** Simulate exam conditions to test your knowledge.") |