Spaces:
Runtime error
Runtime error
Upload app_1.py
Browse files
app_1.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import os
|
| 4 |
+
import PyPDF2 as pdf
|
| 5 |
+
import google.generativeai as genai
|
| 6 |
+
|
| 7 |
+
load_dotenv()
|
| 8 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 9 |
+
|
| 10 |
+
def get_gemini_response(input):
|
| 11 |
+
model = genai.GenerativeModel('gemini-pro')
|
| 12 |
+
response = model.generate_content(input)
|
| 13 |
+
return response.text
|
| 14 |
+
|
| 15 |
+
def input_pdf_setup(uploaded_file):
|
| 16 |
+
reader = pdf.PdfReader(uploaded_file)
|
| 17 |
+
text = ""
|
| 18 |
+
for page in reader.pages:
|
| 19 |
+
text += str(page.extract_text())
|
| 20 |
+
return text
|
| 21 |
+
|
| 22 |
+
# Input prompts
|
| 23 |
+
input_prompt1 = """
|
| 24 |
+
As an experienced Technical Human Resource Manager, your responsibility is to assess the suitability of the provided resume for the specified job description.
|
| 25 |
+
Please provide your expert evaluation on whether the candidate's profile aligns with the role.
|
| 26 |
+
Identify and discuss the candidate's strengths and weaknesses in relation to the job requirements.
|
| 27 |
+
Resume Content:
|
| 28 |
+
{text}
|
| 29 |
+
Job Description:
|
| 30 |
+
{input_text}
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
input_prompt3 = """
|
| 34 |
+
You are a skilled ATS (Applicant Tracking System) scanner with a profound understanding of data science and ATS functionality.
|
| 35 |
+
Your task is to evaluate the resume against the provided job description.
|
| 36 |
+
Provide the percentage match of the resume with the job description, followed by the list of missing keywords, if any, and your final thoughts.
|
| 37 |
+
Resume Content:
|
| 38 |
+
{text}
|
| 39 |
+
Job Description:
|
| 40 |
+
{input_text}
|
| 41 |
+
"""
|
| 42 |
+
input_prompt4 ="""
|
| 43 |
+
You are tasked with providing a concise overall assessment of the resume's quality and suitability for the job.
|
| 44 |
+
Analyze the resume content and provide a brief summary of its strengths, weaknesses, and overall suitability for the specified job description.
|
| 45 |
+
Resume Content:
|
| 46 |
+
{text}
|
| 47 |
+
Job Description:
|
| 48 |
+
{input_text}
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
st.set_page_config(page_title="ATS Resume Expert")
|
| 52 |
+
st.header("ATS Tracking System")
|
| 53 |
+
|
| 54 |
+
input_text = st.text_area("Job Description:", key="input")
|
| 55 |
+
|
| 56 |
+
min_confidence = st.slider("Minimum Confidence", min_value=0.0, max_value=1.0, value=0.5, step=0.01)
|
| 57 |
+
use_keywords = st.checkbox("Use Keywords Analysis")
|
| 58 |
+
|
| 59 |
+
with st.sidebar:
|
| 60 |
+
st.title("Menu:")
|
| 61 |
+
uploaded_file = st.file_uploader("Upload your resume (PDF)...", type=["pdf"])
|
| 62 |
+
if uploaded_file is not None:
|
| 63 |
+
st.success("Done")
|
| 64 |
+
|
| 65 |
+
submit1 = st.button("Tell Me About the Resume")
|
| 66 |
+
submit3 = st.button("Percentage match")
|
| 67 |
+
submit4 = st.button("Assess Overall Resume Quality")
|
| 68 |
+
|
| 69 |
+
if submit1:
|
| 70 |
+
if uploaded_file is not None and input_text:
|
| 71 |
+
pdf_content = input_pdf_setup(uploaded_file)
|
| 72 |
+
response = get_gemini_response(input_prompt1.format(text=pdf_content, input_text=input_text))
|
| 73 |
+
st.subheader("Evaluation of the Resume")
|
| 74 |
+
st.write(response)
|
| 75 |
+
st.session_state['uploaded_file'] = None
|
| 76 |
+
else:
|
| 77 |
+
st.write("Please upload the resume and provide the job description.")
|
| 78 |
+
|
| 79 |
+
if submit3:
|
| 80 |
+
if uploaded_file is not None and input_text:
|
| 81 |
+
pdf_content = input_pdf_setup(uploaded_file)
|
| 82 |
+
response = get_gemini_response(input_prompt3.format(text=pdf_content, input_text=input_text))
|
| 83 |
+
st.subheader("Matching Percentage and Analysis")
|
| 84 |
+
st.write(response)
|
| 85 |
+
st.session_state['uploaded_file'] = None
|
| 86 |
+
else:
|
| 87 |
+
st.write("Please upload the resume and provide the job description.")
|
| 88 |
+
|
| 89 |
+
if submit4:
|
| 90 |
+
if uploaded_file is not None and input_text:
|
| 91 |
+
pdf_content = input_pdf_setup(uploaded_file)
|
| 92 |
+
response = get_gemini_response(input_prompt4.format(text=pdf_content, input_text=input_text))
|
| 93 |
+
st.subheader("Overall Resume Quality Assessment")
|
| 94 |
+
st.write(response)
|
| 95 |
+
st.session_state['uploaded_file'] = None
|
| 96 |
+
else:
|
| 97 |
+
st.write("Please upload the resume and provide the job description.")
|