Spaces:
Sleeping
Sleeping
Update resume.py
Browse files1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374751 unmodified linefrom PyPDF2 import PdfReaderimport google.generativeai as genai# Function to extract text from PDFdef extract_pdf_text(file):try:reader = PdfReader(file)text = ""for page in reader.pages:text += page.extract_text() or ""return textexcept:return ""# Function to get AI analysisdef analyze_resume(resume_text, api_key, job_description):try:genai.configure(api_key=api_key)model = genai.GenerativeModel('gemini-1.5-flash-8b')prompt = f"""Review this resume for the following role:- Assign a Match Score (0-100)% based on alignment with the job description.- List 3 matching keywords and 3 missing keywords.- Highlight 2 strengths and 2 gaps.- Suggest 2 improvements.- Verdict: Strong, Average, or Needs Work.Job Description: {job_description}Resume: {resume_text}"""response = model.generate_content(prompt)return response.textexcept Exception as e:return f"Error: {e}"# Streamlit appst.title("Resume Checker for Data Analyst")st.write("Enter your Gemini API key, job description, and upload your resume (PDF).")# API key inputapi_key = st.text_input("Enter Gemini API Key", type="password")# Job description inputjob_description = st.text_area("Enter Job Description", height=150)# File uploaderuploaded_file = st.file_uploader("Upload PDF Resume", type=["pdf"])if uploaded_file and api_key and job_description:resume_text = extract_pdf_text(uploaded_file)if resume_text:if st.button("Analyze Resume"):with st.spinner("Analyzing..."):result = analyze_resume(resume_text, api_key, job_description)st.subheader("Resume Analysis")st.write(result)else:st.error("Could not extract text from PDF. Use a text-based PDF.")elif not api_key:st.warning("Please enter your Gemini API key.")elif not job_description:st.warning("Please enter a job description.")else:st.info("Upload a PDF resume to start.")# Footerst.markdown("---")st.markdown("""<div style='text-align: center; font-size: 15px;'>Made with โค๏ธ by <b>Shashank Kashyap</b> | Founder of <a href='https://flexingdata.com' target='_blank'><b>Flexing Data</b></a><br>Empowering future Data Analysts with AI-driven tools & industry-ready profiles.<br><br>๐ <a href='https://flexingdata.com' target='_blank'>Visit Website</a> |๐ <a href='https://www.linkedin.com/in/imshashankashyap/' target='_blank'>Connect on LinkedIn</a></div>""", unsafe_allow_html=True)1 unmodified line2345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152531 unmodified linefrom PyPDF2 import PdfReaderimport google.generativeai as genai# PDF text extractordef pdf_to_text(pdf):reader = PdfReader(pdf)text = "".join(page.extract_text() or "" for page in reader.pages)return text# Gemini AI resume analysisdef analyze(api_key, job_desc, resume):genai.configure(api_key=api_key)model = genai.GenerativeModel('gemini-1.5-flash-8b')prompt = f"""Analyze the resume for this role:Job Description: {job_desc}Resume: {resume}Provide:- Match Score (0-100)%- 3 Matching Keywords- 3 Missing Keywords- 2 Strengths- 2 Gaps- 2 Improvement suggestions- Verdict: Strong, Average, or Needs Work."""return model.generate_content(prompt).text# Streamlit UIst.title("๐ Resume Checker")st.write("Check your resume against a job description using AI.")api_key = st.text_input("Gemini API Key", type="password")job_desc = st.text_area("Job Description")pdf = st.file_uploader("Upload Resume (PDF)", type="pdf")if st.button("Analyze"):if api_key and job_desc and pdf:resume_text = pdf_to_text(pdf)if resume_text:with st.spinner("Analyzing..."):result = analyze(api_key, job_desc, resume_text)st.write(result)else:st.error("Can't extract text from PDF. Use a text-based PDF.")else:st.warning("Please provide API key, job description, and resume.")st.markdown("""---Made with โค๏ธ by [Shashank Kashyap](https://flexingdata.com) |[LinkedIn](https://www.linkedin.com/in/imshashankashyap/) ๐ [Flexing Data](https://flexingdata.com)""", unsafe_allow_html=True)
resume.py+43-65