import base64 import streamlit as st import os import io import pdf2image import google.generativeai as genai from dotenv import load_dotenv 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 def app(): #st.set_page_config(page_icon="img.png", page_title="ATS Resume Expert") st.header("ATS Tracking System") input_text = st.text_area("Job Description: ", key="input") uploaded_file = st.file_uploader("Upload your resume(PDF)...", type="pdf") 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") submit4 = st.button("What are the keywords that are missing ") input_prompt1 = """ You are an experienced Technical Human Resource Manager,your task is to review the provided resume against the job description. 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 skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science,machine learning , AI,Data analyist and ATS functionality,your task is to review the provided resume against the job description.Please share your professional evaluation on how the candidate's Can Improve the skills with the role. Highlight the keypoints how the candidate can improve the skills in relation to the specified job requirements """ input_prompt3 = """ You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science and ATS functionality, your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matchesthe job description. First the output should come as percentage and then keywords missing and last final thoughts. """ input_prompt4 = """ You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science and ATS functionality,your task is to evaluate the resume against the provided job description. give me the missing keywords and matching keywords of resume and if the resume matchesappreciate the candidate in front of HR by explaining the projects Candidate have done in the past.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 uplaod the resume") elif submit2: if uploaded_file is not None: pdf_content = input_pdf_setup(uploaded_file) response = get_gemini_response(input_prompt2, pdf_content, input_text) st.subheader("The Repsonse is") st.write(response) else: st.write("Please uplaod 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") elif submit4: if uploaded_file is not None: pdf_content = input_pdf_setup(uploaded_file) response = get_gemini_response(input_prompt4, pdf_content, input_text) st.subheader("The Repsonse is") st.write(response) else: st.write("Please uplaod the resume") if __name__ == "__main__": app()