Spaces:
Build error
Build error
| import streamlit as st | |
| import os | |
| import io | |
| import base64 | |
| from PIL import Image | |
| import pdf2image | |
| import google.generativeai as genai | |
| genai.configure(api_key = os.getenv('GEN_AI_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 pdf to image | |
| images = pdf2image.convert_from_bytes(uploaded_file.read()) | |
| first_page = images[0] | |
| # take image and 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() | |
| } | |
| ] | |
| return pdf_parts | |
| else: | |
| raise FileNotFoundError("No File uploaded") | |
| # Streamlit app | |
| st.set_page_config(page_title = "ATS Resume Analyser") | |
| st.header("ATS Tracker") | |
| input_text = st.text_area("Job Description: ", key = "input") | |
| uploaded_file = st.file_uploader("Upload your resume in pdf format...", 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 improve my skills") | |
| # submit3 = st.button("What are the missing keywords in my resume") | |
| submit3 = st.button("Percentage match to Job description") | |
| input_prompt1 = """ | |
| You are an experienced Technical Human Resource Manager with tech experience with experience in data science, LLMs, | |
| machine learning, deep learning, devops and data analyst, | |
| your task is to review the provided resume and share your professional evaluation on | |
| whether the candidate's profile aligns with the Job description. Highlight the strengths and weakness of the applicant | |
| in relation to the specified job description | |
| """ | |
| input_prompt3 = """ | |
| You are skilled ATS (Application Tracking System) scanner with a deep understanding of any one job role data science, LLMs, | |
| machine learning, deep learning, devops, data analyst and deep ATS functionality. Your task is to evaluate the given resume against provided job description | |
| Give me a percentage match if the resume matches the job description and should come as a percentage followed by keywords missing in the resume. | |
| """ | |
| if submit1: | |
| if uploaded_file is not None: | |
| pdf_content = input_pdf_setup(uploaded_file) | |
| response = get_gemini_response(input_text, pdf_content, input_prompt1) | |
| st.subheader("The response 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_text, pdf_content,input_prompt3) | |
| st.subheader("The response is: ") | |
| st.write(response) | |
| else: | |
| st.write("Please upload the resume") | |