Spaces:
Sleeping
Sleeping
File size: 4,283 Bytes
b4e2fdc 82e1a48 b154a6b 9f9c373 82e1a48 b154a6b 82e1a48 b154a6b 7cc01d4 b154a6b 7cc01d4 b154a6b 7cc01d4 b154a6b 82e1a48 b154a6b 82e1a48 7cc01d4 82e1a48 9f9c373 b4e2fdc 82e1a48 b4e2fdc b154a6b 82e1a48 9f9c373 b154a6b 9f9c373 82e1a48 b154a6b 82e1a48 b154a6b 82e1a48 b154a6b 82e1a48 b154a6b 7cc01d4 b154a6b 7cc01d4 82e1a48 b4e2fdc b154a6b 82e1a48 7cc01d4 84f4b0d 82e1a48 b154a6b 82e1a48 7cc01d4 82e1a48 b4e2fdc b154a6b 82e1a48 b154a6b 82e1a48 b154a6b |
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
import streamlit as st
import os
import openai
from docx import Document
from docx.shared import Pt
# === Page Setup ===
st.set_page_config(page_title="π Smart Career Advisor", layout="centered")
# === Groq API Key Setup ===
openai.api_key = os.getenv("GROQ_API_KEY") # Set this in Hugging Face > Settings > Secrets
MODEL = "llama3-70b-8192"
# === Query Function ===
def query_groq(prompt):
try:
response = openai.ChatCompletion.create(
model=MODEL,
messages=[{"role": "user", "content": prompt}]
)
return response.choices[0].message["content"]
except Exception as e:
return f"β Error: {str(e)}"
# === Word Export Function ===
def generate_doc(user_name, content):
doc = Document()
heading = doc.add_heading(user_name, level=1)
heading.alignment = 1 # center
style = doc.styles['Normal']
font = style.font
font.name = 'Arial'
font.size = Pt(11)
for section in content.split('\n\n'):
if section.strip():
doc.add_paragraph(section.strip())
filename = f"{user_name.replace(' ', '_')}_Career_Report.docx"
doc.save(filename)
return filename
# === Sidebar Inputs ===
with st.sidebar:
st.image("https://img.icons8.com/fluency/96/graduation-cap.png", width=100)
st.title("π§ User Profile")
user_name = st.text_input("π€ Full Name")
education = st.selectbox("π Education Level", ["Matric", "Intermediate", "Bachelor", "Master", "M.Phil", "PhD"])
major = st.text_input("π Field of Study / Major")
interests = st.multiselect("π― Interests", [
"Technology", "Arts", "Business", "Education", "Healthcare", "Design", "Public Service"
])
work_style = st.radio("π’ Preferred Work Style", ["Remote", "Field-based", "Office", "Freelance"])
goal = st.selectbox("π Career Goal", ["High Income", "Flexibility", "Social Impact", "Research"])
skills = st.text_area("π οΈ Skills or Strengths", placeholder="e.g., leadership, coding, communication")
industry = st.text_input("π Preferred Industry (optional)")
submit = st.button("π Generate Career Report")
# === Main Title ===
st.markdown("<h1 style='text-align:center; color:#4B8BBE;'>π Smart Career Advisor</h1>", unsafe_allow_html=True)
st.markdown("<p style='text-align:center;'>Get personalized career suggestions using GenAI</p>", unsafe_allow_html=True)
# === Main Logic ===
if submit and user_name and interests:
st.info("π Processing your profile. Please wait...")
user_profile = f"""
Name: {user_name}
Education: {education}
Major: {major}
Interests: {', '.join(interests)}
Work Style: {work_style}
Career Goal: {goal}
Skills: {skills}
Preferred Industry: {industry}
"""
prompt = f"""
You are a professional career counselor. Based on this user profile, generate a career guidance report in 5 sections:
1. Suggested Career Paths
2. Common Job Roles or Occupations
3. Required Skills or Certifications
4. Recommended Learning Resources (online courses, platforms)
5. Tips to Get Started
User Profile:
{user_profile}
"""
response = query_groq(prompt)
# === Display Results ===
st.success("β
Career Report Generated!")
for section in response.split('\n\n'):
if section.strip():
with st.expander(section.strip().split('\n')[0]):
st.markdown(section.strip())
# === Word File Download ===
file_path = generate_doc(user_name, response)
with open(file_path, "rb") as file:
st.download_button(
label="β¬οΈ Download Report as MS Word",
data=file,
file_name=file_path,
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)
# === Footer Developer Info ===
st.markdown("---")
st.markdown("**π¨βπ» Developed by Najaf Ali Sharqi**")
st.markdown("""
**About the Developer:**
Najaf Ali Sharqi is an experienced educationist and AI integration specialist with a passion for building inclusive, smart applications for educators and students in low-resource settings.
He specializes in curriculum development, GenAI tools, and digital innovation in the education sector.
""")
|