import os import io import streamlit as st import pdf2image import google.generativeai as genai import base64 from PIL import Image from dotenv import load_dotenv from time import sleep # Load environment variables load_dotenv() # Configure generative AI genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) # Function to generate a response using generative AI def get_gemini_response(input, pdf_content, prompt): model = genai.GenerativeModel("gemini-1.5-flash") response = model.generate_content([input, pdf_content[0], prompt]) return response.text # Function to process uploaded PDF and extract content def input_pdf_setup(uploaded_file): if uploaded_file is not None: images = pdf2image.convert_from_bytes(uploaded_file.read()) first_page = images[0] 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") # Prompts for Generative AI input_prompt1 = """ You are an experienced HR with Technical Experience in the field of any one job role from Data Science, Data Analyst, DevOPS, Machine Learning Engineer, Prompt Engineer, AI Engineer, Full Stack Web Development, Big Data Engineering, Marketing Analyst, Human Resource Manager, Software Developer 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 skilled ATS (Applicant Tracking System) scanner with a deep understanding of any one job role from Data Science, Data Analyst, DevOPS, Machine Learning Engineer, Prompt Engineering, AI Engineer, Full Stack Web Development, Big Data Engineering, Marketing Analyst, Human Resource Manager, Software Developer and deep ATS functionality, your task is to evaluate the resume against the provided job description, give me only the Percentage of match if the resume matches the job description. First the output should come as Percentage and then list of Keywords Missing and last final thoughts. """ # Set STREAMLIT page configuration st.set_page_config( page_title="Application Tracking System", page_icon="📝", layout="wide", initial_sidebar_state="collapsed" ) # Add custom CSS and animations st.markdown(""" """, unsafe_allow_html=True) # Main title st.markdown("

AI Resume Analyzing System

", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) st.markdown("

Analyze & Optimize your Resume for top job opportunities with AI insights

", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) # Upload Section st.markdown("
", unsafe_allow_html=True) st.markdown("

📁 Upload Your Resume & 📃Job Description

", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) col1, col2 = st.columns([1, 2]) with col1: uploaded_file = st.file_uploader("Upload Resume (PDF only):", type=["PDF"]) with col2: input_text = st.text_area("Job Description:", placeholder="Enter job description here...") if uploaded_file is not None: st.success("Resume Uploaded Successfully ✅") else: st.warning("Please upload your resume to proceed.") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) # Action Section st.markdown("
", unsafe_allow_html=True) st.markdown("

👉🏻 Select Your Action

", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) col1, col2 = st.columns([1, 1]) with col1: if st.button("🔎 Analyze Resume", key="analyze", help="Get detailed evaluation of your resume"): if uploaded_file: with st.spinner("Processing..."): pdf_content = input_pdf_setup(uploaded_file) response = get_gemini_response(input_prompt1, pdf_content, input_text) st.success("Analysis Complete!") st.subheader("Evaluation Results:") st.write(response) else: st.error("Please upload a resume to proceed.") with col2: if st.button("📈 PERCENTAGE Match", key="match", help="Find out how well your resume matches the job description"): if uploaded_file: with st.spinner("Calculating match..."): pdf_content = input_pdf_setup(uploaded_file) response = get_gemini_response(input_prompt2, pdf_content, input_text) st.success("Match Calculation Complete!") st.subheader("Match Results:") st.write(response) else: st.error("Please upload a resume to proceed.") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) # Footer Section st.markdown("", unsafe_allow_html=True)