Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from utils import extract_text_from_pdf, calculate_similarity | |
| from resume_generator import get_missing_keywords, generate_latex, generate_pdf | |
| st.set_page_config(page_title="AI Resume Analyzer") | |
| st.title("π€ AI Resume Analyzer") | |
| # ------------------------- | |
| # SESSION STATE | |
| # ------------------------- | |
| if "resume_text" not in st.session_state: | |
| st.session_state.resume_text = None | |
| if "job_desc" not in st.session_state: | |
| st.session_state.job_desc = None | |
| if "keywords" not in st.session_state: | |
| st.session_state.keywords = [] | |
| # ------------------------- | |
| # INPUT | |
| # ------------------------- | |
| uploaded_file = st.file_uploader("Upload Resume", type=["pdf"]) | |
| job_desc = st.text_area("Paste Job Description") | |
| # ------------------------- | |
| # ANALYZE | |
| # ------------------------- | |
| if st.button("π Analyze Resume"): | |
| if uploaded_file and job_desc: | |
| resume_text = extract_text_from_pdf(uploaded_file) | |
| st.session_state.resume_text = resume_text | |
| st.session_state.job_desc = job_desc | |
| score = calculate_similarity(resume_text, job_desc) | |
| st.subheader(f"Match Score: {score}%") | |
| else: | |
| st.warning("Upload resume and enter job description") | |
| # ------------------------- | |
| # AI SUGGESTIONS (KEYWORDS) | |
| # ------------------------- | |
| if st.session_state.resume_text: | |
| if st.button("π‘ Get Missing Keywords"): | |
| keywords = get_missing_keywords( | |
| st.session_state.resume_text, | |
| st.session_state.job_desc | |
| ) | |
| st.session_state.keywords = keywords | |
| st.write("### π Missing Keywords:") | |
| st.write(", ".join(keywords)) | |
| # ------------------------- | |
| # RESUME GENERATION | |
| # ------------------------- | |
| if st.session_state.resume_text: | |
| st.markdown("## π Generate Resume") | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| latex_btn = st.button("π§Ύ Generate LaTeX") | |
| with col2: | |
| pdf_btn = st.button("π₯ Download PDF") | |
| # sample structured data (later you can auto-extract) | |
| data = { | |
| "name": "Jashan Malhotra", | |
| "location": "Bengaluru, India", | |
| "summary": "Software Engineer and Data Analyst", | |
| "skills": st.session_state.keywords if st.session_state.keywords else ["Python", "SQL"] | |
| } | |
| if latex_btn: | |
| latex_code = generate_latex(data) | |
| st.code(latex_code, language="latex") | |
| if pdf_btn: | |
| pdf_file = generate_pdf(data) | |
| st.download_button( | |
| label="Download PDF", | |
| data=pdf_file, | |
| file_name="resume.pdf", | |
| mime="application/pdf" | |
| ) |