ATSapp / app.py
deepshikhar23's picture
Update app.py
7982465 verified
import streamlit as st
import os
import PyPDF2 as pdf
import google.generativeai as genai
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv(dotenv_path='C:/Users/HP/ATSapp/.env')
api_key = os.getenv("GOOGLE_API_KEY")
genai.configure(api_key=api_key)
def gemini_response(prompt, jd_text, resume_text):
# Use the updated model name
model = genai.GenerativeModel(model_name="gemini-1.5-pro")
# Construct input with both JD and resume text
input_text = f"{prompt}\n\nJob Description:\n{jd_text}\n\nResume:\n{resume_text}"
response = model.generate_content(input_text)
return response.text
def input_pdf_text(uploaded_file):
reader = pdf.PdfReader(uploaded_file)
text = ""
for page in range(len(reader.pages)):
page_obj = reader.pages[page]
text += page_obj.extract_text()
return text
# Streamlit app interface
st.title("ATS Resume Scanner")
st.text("Make your resume ATS friendly")
# Get Job Description (JD) and resume from the user
jd = st.text_area("Paste the job description here")
uploaded_file = st.file_uploader("Upload your resume", type="pdf", help="Please upload the pdf")
submit1 = st.button("How is my resume?")
submit2 = st.button("Tell me the keywords that my resume is missing")
submit3 = st.button("Give my resume a matching score out of 10")
if uploaded_file is not None:
st.write("Resume uploaded successfully")
prompt1 = (
"Suppose you are an experienced technical HR manager with 10 years of experience, "
"specializing in resume reviews for tech roles (e.g., Data Science, Data Analyst, Full Stack Developer, DevOps, and Data Engineering). "
"Your task is to review the provided resume against the job description. "
"Please share a detailed and honest evaluation on whether the provided resume aligns with the job description, including strengths and weaknesses."
)
prompt2 = (
"Suppose you are an experienced technical HR manager with 10 years of experience specializing in keyword matching for tech roles (e.g., Data Science, Data Analyst, Full Stack Developer, DevOps, and Data Engineering). "
"Your task is to compare the provided resume against the job description and list the most important keywords that are in the job description but missing in the resume."
)
prompt3 = (
"Suppose you are an experienced technical HR manager with 10 years of experience specializing in ATS systems for tech roles (e.g., Data Science, Data Analyst, Full Stack Developer, DevOps, and Data Engineering). "
"Your task is to score the provided resume out of 10 based on how well it matches the job description. "
"If it doesn't receive a perfect score, please list the necessary changes to improve it."
)
if submit1:
if uploaded_file is not None and jd.strip() != "":
resume_text = input_pdf_text(uploaded_file)
response = gemini_response(prompt1, jd, resume_text)
st.subheader(response)
else:
st.write("Please upload your resume and provide the job description")
elif submit2:
if uploaded_file is not None and jd.strip() != "":
resume_text = input_pdf_text(uploaded_file)
response = gemini_response(prompt2, jd, resume_text)
st.subheader(response)
else:
st.write("Please upload your resume and provide the job description")
elif submit3:
if uploaded_file is not None and jd.strip() != "":
resume_text = input_pdf_text(uploaded_file)
response = gemini_response(prompt3, jd, resume_text)
st.subheader(response)
else:
st.write("Please upload your resume and provide the job description")