Spaces:
Sleeping
Sleeping
File size: 2,971 Bytes
4980dd3 680c973 4980dd3 |
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 |
from dotenv import load_dotenv
load_dotenv()
import streamlit as st
import base64
import os
import io
from PIL import Image
import pdf2image
import google.generativeai as genai
genai.configureapi_key=os.getenv(("GOOGLE_API_KEY"))
def get_gemini_response(input, pdf_content, prompt):
model = genai.GenerativeModel('gemini-pro-vision')
response = model.generative_content([input, pdf_content[0], prompt])
return response.text
def input_pdf_setup(upload_file):
if upload_file is not None:
## Convert PDF to image
images = pdf2image.convert_from_bytes(upload_file.read.read())
first_page = images[0]
# Convert into 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 has been uploaded")
# Streamlit App
st.set_page_config(page_title = "ATS Resume Scanner")
st.header("ATS TRacking System")
input_text = st.text_area("Job DEscription: ", key= "input")
upload_file = st.file_uploader("Upload your resume in PDF format", type="pdf")
if upload_file is not None:
st.write('PDF uploaded successfully')
submit_btn1 =st.button("Tell me about yourself?")
submit_btn2 =st.button("How can I improve my skills?")
submit_btn3 =st.button("Percentage match")
# THis is the prompt for the GENAI to act as a HR Tech Recruiter
input_prompt1 = """
You are an experienced Tech HR specializing in data science, full-stack web development, and big data engineering. Utilize our advanced Tech HR LLM to review provided resumes against corresponding job descriptions for these roles. Ensure seamless alignment of candidate qualifications with specific skill sets and requirements.
"""
# THis is the prompt for the GENAI to act as an ATS System
input_prompt2 = """
a proficient Tech HR specialist adept in arts, devops, and related fields. Employ our Tech HR LLM to meticulously review resumes against corresponding job descriptions. Ensure seamless alignment between candidate qualifications and specific skill sets for optimal recruitment outcomes.
"""
if submit_btn1:
if upload_file is not None:
pdf_content= input_pdf_setup(upload_file)
response = get_gemini_response(input_prompt1, pdf_content, input_text)
st.subheader("The response is:")
st.write(response)
else:
st.write("Please upload the resume")
elif submit_btn2:
if upload_file is not None:
pdf_content= input_pdf_setup(upload_file)
response = get_gemini_response(input_prompt2, pdf_content, input_text)
st.subheader("The response is:")
st.write(response)
else:
st.write("Please upload the resume") |