-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
95 lines (76 loc) · 3.77 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from dotenv import load_dotenv
import base64
import streamlit as st
import os
import io
from PIL import Image
import pdf2image
import google.generativeai as genai
load_dotenv()
genai.configure(api_key =os.getenv("Google_API_Key"))
def get_gemini_response(input,pdf_content,prompt):
model = genai.GenerativeModel('gemini-pro-vision')
response = model.generate_content([input,pdf_content[0],prompt])
return response.text
def input_pdf_setup(uploaded_file):
if uploaded_file is not None:
## Convert the PDF to image
images=pdf2image.convert_from_bytes(uploaded_file.read())
first_page=images[0]
# Convert to bytes
img_byte_arr = io.BytesIO()
first_page.save(img_byte_arr, format='JPEG')
img_byte_arr = img_byte_arr.getvalue()
pdf_parts = [
{
"mime_type": "image/jpeg",
"data": base64.b64encode(img_byte_arr).decode() # encode to base64
}
]
return pdf_parts
else:
raise FileNotFoundError("No file uploaded")
## Streamlit App
st.set_page_config(page_title="ATS Resume Expert")
st.header("ATS Tracking System")
input_text=st.text_area("Job Description: ",key="input") #JD
uploaded_file=st.file_uploader("Upload your resume(PDF)...",type=["pdf"]) # Resume
if uploaded_file is not None:
st.write("PDF Uploaded Successfully")
submit1 = st.button("Tell Me About the Resume")
#submit2 = st.button("How Can I Improvise my Skills")
submit3 = st.button("Percentage match")
input_prompt1 = """
You are an experienced Human Resource Manager,with expertise in Various Computer Science fields ( any one of the following) like Data Science, Full Stack Web Development, Mobile App Development, Blockchain Development, Computer Vision, Cybersecurity
and your task is to review the provided resume against the job description for these profiles.
Please share your professional evaluation on whether the candidate's profile aligns with the role.
Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
"""
input_prompt2 = """
You are an experienced Human Resource Manager,with expertise in Various Computer Science fields ( any one of the following) like Data Science, Full Stack Web Development, Mobile App Development, Blockchain Development, Computer Vision, Cybersecurity
and your task is to scrutinize the provided resume in the light of the job description for these profiles.
Share your insights on the candidate's suitability for the role from a HR perspective.
Additionally offer insights and suggestions on enhancing the candidate's skill and identify areas where work is needed.
""" # does the same as Button 1 - can be removed.
input_prompt3 = """
You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of Data Science, Full Stack Web Development, Mobile App Development, Blockchain Development, Computer Vision, Cybersecurity and deep
ATS functionality,
your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matches
the job description. First the output should come as percentage and then keywords missing and last final thoughts.
"""
if submit1:
if uploaded_file is not None:
pdf_content=input_pdf_setup(uploaded_file)
response=get_gemini_response(input_prompt1,pdf_content,input_text)
st.subheader("The Repsonse is")
st.write(response)
else:
st.write("Please upload the resume")
elif submit3:
if uploaded_file is not None:
pdf_content=input_pdf_setup(uploaded_file)
response=get_gemini_response(input_prompt3,pdf_content,input_text)
st.subheader("The Repsonse is")
st.write(response)
else:
st.write("Please uplaod the resume")