Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
from groq import Groq
|
| 4 |
from docx import Document
|
| 5 |
from docx.shared import Pt
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
# ==== PAGE CONFIG ====
|
| 10 |
st.set_page_config(page_title="Smart Career Advisor", layout="centered")
|
| 11 |
|
| 12 |
-
# ====
|
| 13 |
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 14 |
MODEL = "llama3-70b-8192"
|
| 15 |
|
|
|
|
| 16 |
def query_groq(prompt):
|
| 17 |
try:
|
| 18 |
response = client.chat.completions.create(
|
|
@@ -23,24 +23,27 @@ def query_groq(prompt):
|
|
| 23 |
except Exception as e:
|
| 24 |
return f"Error: {str(e)}"
|
| 25 |
|
| 26 |
-
# ====
|
| 27 |
with st.sidebar:
|
| 28 |
-
st.title("π§ User Input")
|
| 29 |
user_name = st.text_input("π€ Your Full Name")
|
| 30 |
education = st.selectbox("π Education Level", ["Matric", "Intermediate", "Bachelor", "Master", "PhD"])
|
| 31 |
major = st.text_input("π Field of Study / Major")
|
| 32 |
-
interests = st.multiselect("π― Interests", [
|
|
|
|
|
|
|
|
|
|
| 33 |
work_style = st.radio("π’ Preferred Work Style", ["Remote", "Field-based", "Office", "Freelance"])
|
| 34 |
goal = st.selectbox("π Career Goal", ["High Income", "Flexibility", "Social Impact", "Research", "Innovation"])
|
| 35 |
skills = st.text_area("π οΈ Your Skills or Strengths", placeholder="e.g., communication, coding, writing")
|
| 36 |
industry = st.text_input("π Preferred Industry (optional)")
|
| 37 |
submit = st.button("π Generate Career Report")
|
| 38 |
|
| 39 |
-
# ====
|
| 40 |
st.title("π Smart Career Advisor")
|
| 41 |
-
st.markdown("
|
| 42 |
|
| 43 |
-
# ====
|
| 44 |
if submit and user_name and interests:
|
| 45 |
user_profile = f"""
|
| 46 |
Name: {user_name}
|
|
@@ -54,37 +57,37 @@ if submit and user_name and interests:
|
|
| 54 |
"""
|
| 55 |
|
| 56 |
groq_prompt = f"""
|
| 57 |
-
You are
|
|
|
|
| 58 |
1. Suitable Career Paths
|
| 59 |
-
2. Job Roles
|
| 60 |
3. Required Skills or Certifications
|
| 61 |
-
4. Recommended Learning Resources
|
| 62 |
-
5. Tips to Get Started
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
USER PROFILE:
|
| 67 |
{user_profile}
|
| 68 |
"""
|
| 69 |
|
| 70 |
with st.spinner("π Analyzing your profile..."):
|
| 71 |
-
|
| 72 |
|
| 73 |
-
# ==== DISPLAY RESULT ====
|
| 74 |
st.success("β
Career Report Generated")
|
| 75 |
-
st.markdown(f"**Name:** {user_name}")
|
| 76 |
-
|
| 77 |
-
sections =
|
| 78 |
-
for
|
| 79 |
-
if
|
| 80 |
-
with st.expander(
|
| 81 |
-
st.markdown(
|
| 82 |
|
| 83 |
-
# ====
|
| 84 |
st.markdown("---")
|
| 85 |
st.markdown("**π¨βπ» Developed by Najaf Ali Sharqi**")
|
| 86 |
st.markdown("""
|
| 87 |
**About the Developer:**
|
| 88 |
Najaf Ali Sharqi is an educationist and AI trainer with a strong background in Educational Technology and Curriculum Development.
|
| 89 |
-
He specializes in developing user-friendly GenAI tools for educators and students in low-resource environments
|
| 90 |
""")
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
from groq import Groq
|
| 4 |
from docx import Document
|
| 5 |
from docx.shared import Pt
|
| 6 |
+
from datetime import datetime
|
| 7 |
|
| 8 |
+
# ==== Streamlit Page Config ====
|
|
|
|
|
|
|
| 9 |
st.set_page_config(page_title="Smart Career Advisor", layout="centered")
|
| 10 |
|
| 11 |
+
# ==== Groq Client Setup ====
|
| 12 |
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 13 |
MODEL = "llama3-70b-8192"
|
| 14 |
|
| 15 |
+
# ==== Groq Query Function ====
|
| 16 |
def query_groq(prompt):
|
| 17 |
try:
|
| 18 |
response = client.chat.completions.create(
|
|
|
|
| 23 |
except Exception as e:
|
| 24 |
return f"Error: {str(e)}"
|
| 25 |
|
| 26 |
+
# ==== Sidebar Inputs ====
|
| 27 |
with st.sidebar:
|
| 28 |
+
st.title("π§ User Profile Input")
|
| 29 |
user_name = st.text_input("π€ Your Full Name")
|
| 30 |
education = st.selectbox("π Education Level", ["Matric", "Intermediate", "Bachelor", "Master", "PhD"])
|
| 31 |
major = st.text_input("π Field of Study / Major")
|
| 32 |
+
interests = st.multiselect("π― Interests", [
|
| 33 |
+
"Technology", "Arts", "Business", "Healthcare", "Teaching",
|
| 34 |
+
"Design", "Public Service", "Engineering", "Law", "Science"
|
| 35 |
+
])
|
| 36 |
work_style = st.radio("π’ Preferred Work Style", ["Remote", "Field-based", "Office", "Freelance"])
|
| 37 |
goal = st.selectbox("π Career Goal", ["High Income", "Flexibility", "Social Impact", "Research", "Innovation"])
|
| 38 |
skills = st.text_area("π οΈ Your Skills or Strengths", placeholder="e.g., communication, coding, writing")
|
| 39 |
industry = st.text_input("π Preferred Industry (optional)")
|
| 40 |
submit = st.button("π Generate Career Report")
|
| 41 |
|
| 42 |
+
# ==== Main Title ====
|
| 43 |
st.title("π Smart Career Advisor")
|
| 44 |
+
st.markdown("A GenAI-powered app to help you explore career options based on your interests, education, and goals.")
|
| 45 |
|
| 46 |
+
# ==== Generate Career Report ====
|
| 47 |
if submit and user_name and interests:
|
| 48 |
user_profile = f"""
|
| 49 |
Name: {user_name}
|
|
|
|
| 57 |
"""
|
| 58 |
|
| 59 |
groq_prompt = f"""
|
| 60 |
+
You are an expert career advisor. Based on the following user profile, generate a detailed career guidance report with 5 clear sections:
|
| 61 |
+
|
| 62 |
1. Suitable Career Paths
|
| 63 |
+
2. Common Job Roles or Occupations
|
| 64 |
3. Required Skills or Certifications
|
| 65 |
+
4. Recommended Online Learning Resources
|
| 66 |
+
5. Practical Tips to Get Started
|
| 67 |
|
| 68 |
+
Be practical and motivational.
|
| 69 |
|
| 70 |
USER PROFILE:
|
| 71 |
{user_profile}
|
| 72 |
"""
|
| 73 |
|
| 74 |
with st.spinner("π Analyzing your profile..."):
|
| 75 |
+
response = query_groq(groq_prompt)
|
| 76 |
|
|
|
|
| 77 |
st.success("β
Career Report Generated")
|
| 78 |
+
st.markdown(f"**π€ Name:** {user_name}")
|
| 79 |
+
|
| 80 |
+
sections = response.split('\n\n')
|
| 81 |
+
for section in sections:
|
| 82 |
+
if section.strip():
|
| 83 |
+
with st.expander(section.strip().split('\n')[0]):
|
| 84 |
+
st.markdown(section.strip())
|
| 85 |
|
| 86 |
+
# ==== Footer ====
|
| 87 |
st.markdown("---")
|
| 88 |
st.markdown("**π¨βπ» Developed by Najaf Ali Sharqi**")
|
| 89 |
st.markdown("""
|
| 90 |
**About the Developer:**
|
| 91 |
Najaf Ali Sharqi is an educationist and AI trainer with a strong background in Educational Technology and Curriculum Development.
|
| 92 |
+
He specializes in developing user-friendly GenAI tools for educators and students in low-resource environments and is passionate about integrating technology with social impact.
|
| 93 |
""")
|