Turbiling commited on
Commit
b4e2fdc
Β·
verified Β·
1 Parent(s): 5a211a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -28
app.py CHANGED
@@ -1,18 +1,18 @@
1
- import os
2
- from datetime import datetime
3
  from groq import Groq
4
  from docx import Document
5
  from docx.shared import Pt
 
6
 
7
- import streamlit as st
8
-
9
- # ==== PAGE CONFIG ====
10
  st.set_page_config(page_title="Smart Career Advisor", layout="centered")
11
 
12
- # ==== GROQ CLIENT SETUP ====
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
- # ==== SIDEBAR FORM ====
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", ["Technology", "Arts", "Business", "Healthcare", "Teaching", "Design", "Public Service", "Engineering", "Law", "Science"])
 
 
 
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
- # ==== MAIN TITLE ====
40
  st.title("πŸŽ“ Smart Career Advisor")
41
- st.markdown("AI-powered suggestions based on your background and preferences.")
42
 
43
- # ==== MAIN LOGIC ====
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 a professional career counselor. Based on the following user profile, provide a comprehensive advisory report in 5 clear sections:
 
58
  1. Suitable Career Paths
59
- 2. Job Roles/Occupations
60
  3. Required Skills or Certifications
61
- 4. Recommended Learning Resources
62
- 5. Tips to Get Started
63
 
64
- Please be specific, practical, and professional.
65
 
66
  USER PROFILE:
67
  {user_profile}
68
  """
69
 
70
  with st.spinner("πŸ” Analyzing your profile..."):
71
- groq_response = query_groq(groq_prompt)
72
 
73
- # ==== DISPLAY RESULT ====
74
  st.success("βœ… Career Report Generated")
75
- st.markdown(f"**Name:** {user_name}")
76
-
77
- sections = groq_response.split('\n\n')
78
- for sec in sections:
79
- if sec.strip():
80
- with st.expander(sec.strip().split('\n')[0]):
81
- st.markdown(sec.strip())
82
 
83
- # ==== FOOTER ====
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, and is passionate about integrating technology with social impact.
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
  """)