Danial7 commited on
Commit
bbd468a
Β·
verified Β·
1 Parent(s): 03c193d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -53
app.py CHANGED
@@ -1,60 +1,65 @@
1
  import streamlit as st
 
 
 
2
  from utils import (
3
- detect_cv_field,
4
- get_skills_suggestions,
5
- get_certifications,
6
- get_scholarships,
7
- get_education_opportunities,
8
- get_visa_opportunities,
 
9
  )
10
 
11
- st.set_page_config(page_title="Universal Smart CV Analyzer", layout="wide")
 
12
 
13
- st.title("πŸ“„ Universal Smart CV Analyzer & Career Roadmap Generator")
14
-
15
- uploaded_file = st.file_uploader("Upload your CV (TXT or PDF recommended)", type=["txt", "pdf"])
16
 
17
  if uploaded_file:
18
- file_text = uploaded_file.read()
19
- try:
20
- text = file_text.decode("utf-8")
21
- except UnicodeDecodeError:
22
- import PyPDF2
23
- pdf_reader = PyPDF2.PdfReader(uploaded_file)
24
- text = ""
25
- for page in pdf_reader.pages:
26
- text += page.extract_text()
27
-
28
- st.subheader("CV Summary")
29
- st.write(text[:1000] + "...")
30
-
31
- # --- Step 1: Identify field ---
32
- field = detect_cv_field(text)
33
- st.success(f"🧭 Detected Field: **{field.title()}**")
34
-
35
- # --- Step 2: Personalized Suggestions ---
36
- st.subheader("πŸ”§ Recommended Skill Improvements")
37
- skills = get_skills_suggestions(field)
38
- st.write(skills)
39
-
40
- st.subheader("πŸ“œ Relevant Certifications")
41
- certs = get_certifications(field)
42
- st.write(certs)
43
-
44
- st.subheader("πŸŽ“ Scholarship Opportunities")
45
- scholarships = get_scholarships(field)
46
- st.write(scholarships)
47
-
48
- st.subheader("🏫 Higher Education Opportunities")
49
- education = get_education_opportunities(field)
50
- st.write(education)
51
-
52
- st.subheader("🌍 Suggested Visa Pathways")
53
- visa_paths = get_visa_opportunities(field)
54
- st.write(visa_paths)
55
-
56
- # --- Final Counseling Advice ---
57
- st.subheader("πŸ§‘β€πŸ’Ό Career Counselor Advice")
58
- st.markdown(f"""
59
- Based on your background in **{field.title()}**, consider deepening your expertise in the top in-demand tools and seeking international opportunities through scholarships and visa-friendly countries. You may benefit from completing a few certifications like **{certs[0]}** and **{certs[1]}**. Keep your LinkedIn profile up to date and connect with professionals in this space.
60
- """)
 
 
 
1
  import streamlit as st
2
+ import base64
3
+ import os
4
+ import tempfile
5
  from utils import (
6
+ parse_cv,
7
+ identify_field_with_llm,
8
+ generate_skill_score,
9
+ generate_llm_suggestions,
10
+ get_live_jobs,
11
+ generate_counselor_response,
12
+ generate_pdf_report
13
  )
14
 
15
+ st.set_page_config(page_title="Smart CV Analyzer", layout="wide")
16
+ st.title("πŸ“„ Universal Smart CV Analyzer & Career Roadmap")
17
 
18
+ uploaded_file = st.file_uploader("Upload your CV (PDF format)", type=["pdf"])
 
 
19
 
20
  if uploaded_file:
21
+ with st.spinner("Parsing CV..."):
22
+ with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
23
+ tmp_file.write(uploaded_file.read())
24
+ tmp_path = tmp_file.name
25
+
26
+ raw_text = parse_cv(tmp_path)
27
+ os.unlink(tmp_path)
28
+
29
+ st.subheader("🧠 CV Extracted Text")
30
+ st.text_area("Extracted CV Content", raw_text, height=250)
31
+
32
+ with st.spinner("πŸ” Identifying field/domain..."):
33
+ field = identify_field_with_llm(raw_text)
34
+ st.success(f"Detected Field: {field}")
35
+
36
+ with st.spinner("πŸ“Š Generating Skill Score..."):
37
+ score = generate_skill_score(raw_text)
38
+ st.metric("Skill Score (0–100)", score)
39
+
40
+ with st.spinner("🧠 Generating AI-based suggestions..."):
41
+ suggestions = generate_llm_suggestions(raw_text, field)
42
+
43
+ st.subheader("πŸ“Œ Career Suggestions")
44
+ st.markdown(f"**Upskilling Skills:** {', '.join(suggestions['skills'])}")
45
+ st.markdown(f"**Certifications:** {', '.join(suggestions['certifications'])}")
46
+ st.markdown(f"**Scholarships:** {', '.join(suggestions['scholarships'])}")
47
+ st.markdown(f"**Education Opportunities:** {', '.join(suggestions['education'])}")
48
+ st.markdown(f"**Visa Pathways:** {', '.join(suggestions['visa'])}")
49
+
50
+ with st.spinner("🌍 Finding live jobs..."):
51
+ jobs = get_live_jobs(field)
52
+ st.subheader("πŸ’Ό Live Job Opportunities")
53
+ for job in jobs:
54
+ st.markdown(f"- **[{job['title']}]({job['url']})** at *{job['company']}* ({job['location']})")
55
+
56
+ st.subheader("πŸ§‘β€πŸ« Career Counselor Suggestion")
57
+ counselor_msg = generate_counselor_response(raw_text, field, score, suggestions)
58
+ st.info(counselor_msg)
59
+
60
+ # Downloadable report
61
+ st.subheader("πŸ“„ Download Your Personalized Career Report")
62
+ report_bytes = generate_pdf_report(raw_text, field, score, suggestions, jobs, counselor_msg)
63
+ b64 = base64.b64encode(report_bytes).decode()
64
+ href = f'<a href="data:application/pdf;base64,{b64}" download="Career_Roadmap_Report.pdf">πŸ“₯ Download PDF Report</a>'
65
+ st.markdown(href, unsafe_allow_html=True)