Danial7 commited on
Commit
6e1002b
Β·
verified Β·
1 Parent(s): 575bd9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -67
app.py CHANGED
@@ -1,78 +1,60 @@
1
  import streamlit as st
2
  from utils import (
 
3
  get_skills_suggestions,
4
- get_certification_recommendations,
5
- get_scholarship_suggestions,
6
  get_education_opportunities,
7
- get_visa_pathways,
8
- get_job_recommendations,
9
- get_cv_score,
10
- get_field_classification,
11
- get_personalized_advice,
12
  )
13
 
14
- st.set_page_config(page_title="Smart CV Analyzer & Career Roadmap", layout="wide")
15
 
16
- st.title("πŸ“„ Universal Smart CV Analyzer & 🌍 Career Roadmap Generator")
17
- st.markdown("Upload your CV and get a detailed analysis including personalized job suggestions, skill-building advice, education and visa guidance, and a tailored career roadmap.")
18
 
19
- uploaded_file = st.file_uploader("Upload your CV (.txt or .pdf)", type=["txt", "pdf"])
20
 
21
  if uploaded_file:
22
- file_ext = uploaded_file.name.split('.')[-1]
23
- if file_ext == "txt":
24
- cv_text = uploaded_file.read().decode("utf-8")
25
- elif file_ext == "pdf":
26
  import PyPDF2
27
- reader = PyPDF2.PdfReader(uploaded_file)
28
- cv_text = "\n".join(page.extract_text() for page in reader.pages if page.extract_text())
29
- else:
30
- st.error("Unsupported file format.")
31
- st.stop()
32
-
33
- with st.spinner("Analyzing your CV..."):
34
- score = get_cv_score(cv_text)
35
- field = get_field_classification(cv_text)
36
- skills = get_skills_suggestions(cv_text)
37
- certs = get_certification_recommendations(cv_text)
38
- scholarships = get_scholarship_suggestions(cv_text)
39
- education = get_education_opportunities(cv_text)
40
- visa = get_visa_pathways(cv_text, country="USA")
41
- jobs = get_job_recommendations(cv_text, location="USA")
42
- advice = get_personalized_advice(cv_text)
43
-
44
- st.header("πŸ“Š CV Summary")
45
- st.write(f"**Score:** {score}/100")
46
- st.write(f"**Field/Domain:** {field}")
47
-
48
- st.header("πŸ’‘ Personalized Career Advice")
49
- st.success(advice)
50
-
51
- st.header("🧠 Recommended Skills to Learn")
52
- for skill in skills:
53
- st.markdown(f"- {skill}")
54
-
55
- st.header("πŸŽ“ Recommended Certifications")
56
- for cert in certs:
57
- st.markdown(f"- {cert}")
58
-
59
- st.header("🎯 Scholarship Opportunities")
60
- for s in scholarships:
61
- st.markdown(f"- {s}")
62
-
63
- st.header("🏫 Education Paths")
64
- for edu in education:
65
- st.markdown(f"- {edu}")
66
-
67
- st.header("πŸ›‚ Visa Pathways")
68
- for v in visa:
69
- st.markdown(f"- {v}")
70
-
71
- st.header("πŸ’Ό Job Opportunities (USA)")
72
- for job in jobs:
73
- st.subheader(job.get("title", "N/A"))
74
- st.markdown(f"**Company:** {job.get('company', 'Unknown')}")
75
- st.markdown(f"**Location:** {job.get('location', 'Unknown')}")
76
- st.markdown(f"**Description:** {job.get('description', '')[:300]}...")
77
- st.markdown(f"[Apply Here]({job.get('url', '#')})")
78
- st.markdown("---")
 
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
+ """)