Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import base64 | |
| import os | |
| import tempfile | |
| from utils import ( | |
| parse_cv, | |
| identify_field_with_llm, | |
| generate_skill_score, | |
| generate_llm_suggestions, | |
| get_live_jobs, | |
| generate_counselor_response, | |
| generate_pdf_report | |
| ) | |
| st.set_page_config(page_title="Smart CV Analyzer", layout="wide") | |
| st.title("π Universal Smart CV Analyzer & Career Roadmap") | |
| uploaded_file = st.file_uploader("Upload your CV (PDF format)", type=["pdf"]) | |
| if uploaded_file: | |
| with st.spinner("Parsing CV..."): | |
| with tempfile.NamedTemporaryFile(delete=False) as tmp_file: | |
| tmp_file.write(uploaded_file.read()) | |
| tmp_path = tmp_file.name | |
| raw_text = parse_cv(tmp_path) | |
| os.unlink(tmp_path) | |
| st.subheader("π§ CV Extracted Text") | |
| st.text_area("Extracted CV Content", raw_text, height=250) | |
| with st.spinner("π Identifying field/domain..."): | |
| field = identify_field_with_llm(raw_text) | |
| st.success(f"Detected Field: {field}") | |
| with st.spinner("π Generating Skill Score..."): | |
| score = generate_skill_score(raw_text) | |
| st.metric("Skill Score (0β100)", score) | |
| with st.spinner("π§ Generating AI-based suggestions..."): | |
| suggestions = generate_llm_suggestions(raw_text, field) | |
| st.subheader("π Career Suggestions") | |
| st.markdown(f"**Upskilling Skills:** {', '.join(suggestions['skills'])}") | |
| st.markdown(f"**Certifications:** {', '.join(suggestions['certifications'])}") | |
| st.markdown(f"**Scholarships:** {', '.join(suggestions['scholarships'])}") | |
| st.markdown(f"**Education Opportunities:** {', '.join(suggestions['education'])}") | |
| st.markdown(f"**Visa Pathways:** {', '.join(suggestions['visa'])}") | |
| with st.spinner("π Finding live jobs..."): | |
| jobs = get_live_jobs(field) | |
| st.subheader("πΌ Live Job Opportunities") | |
| for job in jobs: | |
| st.markdown(f"- **[{job['title']}]({job['url']})** at *{job['company']}* ({job['location']})") | |
| st.subheader("π§βπ« Career Counselor Suggestion") | |
| counselor_msg = generate_counselor_response(raw_text, field, score, suggestions) | |
| st.info(counselor_msg) | |
| # Downloadable report | |
| st.subheader("π Download Your Personalized Career Report") | |
| report_bytes = generate_pdf_report(raw_text, field, score, suggestions, jobs, counselor_msg) | |
| b64 = base64.b64encode(report_bytes).decode() | |
| href = f'<a href="data:application/pdf;base64,{b64}" download="Career_Roadmap_Report.pdf">π₯ Download PDF Report</a>' | |
| st.markdown(href, unsafe_allow_html=True) | |