Upload 2 files
Browse files- app.py +82 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import io
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
|
4 |
+
load_dotenv()
|
5 |
+
|
6 |
+
import streamlit as st
|
7 |
+
import os
|
8 |
+
from PIL import Image
|
9 |
+
import pdf2image
|
10 |
+
import base64
|
11 |
+
import google.generativeai as genai
|
12 |
+
|
13 |
+
genai.configure(api_key=os.getenv("API_KEY"))
|
14 |
+
|
15 |
+
def get_gemini_response(input, pdf_content,prompt):
|
16 |
+
model = genai.GenerativeModel('gemini-pro-vision')
|
17 |
+
response = model.generate_content([input,pdf_content[0],prompt])
|
18 |
+
return response.text
|
19 |
+
|
20 |
+
def input_pdf_setup(upload_file):
|
21 |
+
if upload_file is not None:
|
22 |
+
images=pdf2image.convert_from_bytes(upload_file.read())
|
23 |
+
|
24 |
+
first_page = images[0]
|
25 |
+
|
26 |
+
img_byte_arr = io.BytesIO()
|
27 |
+
first_page.save(img_byte_arr, format='JPEG')
|
28 |
+
img_byte_arr = img_byte_arr.getvalue()
|
29 |
+
|
30 |
+
pdf_parts = [
|
31 |
+
{
|
32 |
+
"mime_type": "image/jpeg",
|
33 |
+
"data": base64.b64encode(img_byte_arr).decode()
|
34 |
+
}
|
35 |
+
]
|
36 |
+
return pdf_parts
|
37 |
+
else:
|
38 |
+
raise FileNotFoundError("No File uploaded")
|
39 |
+
|
40 |
+
st.set_page_config(page_title="Resume Parser")
|
41 |
+
st.header("Mock ATS")
|
42 |
+
input_text = st.text_area("Paste the job description here: ",key="input")
|
43 |
+
uploaded_file = st.file_uploader("Upload your resume (only PDFs are supported)...", type="pdf")
|
44 |
+
|
45 |
+
if uploaded_file is not None:
|
46 |
+
st.write("Resume uploaded successfully")
|
47 |
+
|
48 |
+
submit1=st.button("Tell me about the resume")
|
49 |
+
|
50 |
+
submit2=st.button("Percentage match with the job description")
|
51 |
+
|
52 |
+
input_prompt1 = """
|
53 |
+
You are an experienced Technical Human Resource Manager,your task is to review the provided resume against the job description.
|
54 |
+
Please share your professional evaluation on whether the candidate's profile aligns with the role.
|
55 |
+
Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
|
56 |
+
"""
|
57 |
+
|
58 |
+
input_prompt2 = """
|
59 |
+
You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science and ATS functionality,
|
60 |
+
your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matches
|
61 |
+
the job description. First the output should come as percentage and then keywords missing and last final thoughts.
|
62 |
+
"""
|
63 |
+
|
64 |
+
if submit1:
|
65 |
+
if uploaded_file is not None:
|
66 |
+
pdf_content=input_pdf_setup(uploaded_file)
|
67 |
+
response=get_gemini_response(input_prompt1,pdf_content,input_text)
|
68 |
+
st.subheader("The Repsonse is")
|
69 |
+
st.write(response)
|
70 |
+
else:
|
71 |
+
st.write("Please uplaod the resume")
|
72 |
+
|
73 |
+
elif submit2:
|
74 |
+
if uploaded_file is not None:
|
75 |
+
pdf_content=input_pdf_setup(uploaded_file)
|
76 |
+
response=get_gemini_response(input_prompt2,pdf_content,input_text)
|
77 |
+
st.subheader("The Repsonse is")
|
78 |
+
st.write(response)
|
79 |
+
else:
|
80 |
+
st.write("Please uplaod the resume")
|
81 |
+
|
82 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
google-generativeai
|
3 |
+
python-dotenv
|
4 |
+
pdf2image
|