|
|
import os |
|
|
import streamlit as st |
|
|
from groq import Groq |
|
|
|
|
|
|
|
|
GROQ_API_KEY = "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" |
|
|
os.environ["GROQ_API_KEY"] = GROQ_API_KEY |
|
|
client = Groq(api_key=os.getenv("GROQ_API_KEY")) |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
) |
|
|
|
|
|
|
|
|
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!") |
|
|
|
|
|
|
|
|
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 |
|
|
) |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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" |
|
|
) |
|
|
|
|
|
response = get_study_plan(prompt) |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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 |
|
|
) |
|
|
|
|
|
|
|
|
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.") |