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'📥 Download PDF Report' st.markdown(href, unsafe_allow_html=True)