Spaces:
Sleeping
Sleeping
Update resume.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import streamlit as stfrom PyPDF2 import PdfReaderimport google.generativeai as genai# Sample job descriptionJOB_DESCRIPTION = """Data Analyst role requiring skills in Excel, SQL, Power BI, Python, and AWS.Tasks: Analyze data, create dashboards, write SQL queries, automate tasks, ensure data quality."""# 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):try:genai.configure(api_key=api_key)model = genai.GenerativeModel('gemini-1.5-flash-8b')prompt = f"""Review this resume for a Data Analyst 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 and upload your resume (PDF) to check alignment with a Data Analyst job.")# API key inputapi_key = st.text_input("Enter Gemini API Key", type="password")# File uploaderuploaded_file = st.file_uploader("Upload PDF Resume", type=["pdf"])if uploaded_file and api_key: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)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.")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)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475import streamlit as stfrom 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)
resume.py+74-75