import streamlit as st import google.generativeai as genai import os import PyPDF2 as pdf from dotenv import load_dotenv import json # Load environment variables load_dotenv() # Configure Google Generative AI genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) # Function to get response from Gemini def get_gemini_response(input): model = genai.GenerativeModel('gemini-pro') response = model.generate_content(input) return response.text # Function to extract text from PDF def input_pdf_text(uploaded_file): if uploaded_file is not None: reader = pdf.PdfReader(uploaded_file) text = "" for page in range(len(reader.pages)): page = reader.pages[page] text += str(page.extract_text()) return text else: return "" # Prompt templates for predefined questions predefined_prompts = { "What needs to improve?": """ As a skilled ATS with a deep understanding of the tech field, software engineering, data science, data analysis, and big data engineering, evaluate the resume based on the given job description. Provide feedback on what needs to be improved in the resume in concise, bullet points, and short, containing useful tips relevant to the job description. resume: {text} description: {jd} """, "How well does my resume match the job description?": """ As a skilled ATS with a deep understanding of the tech field, software engineering, data science, data analysis, and big data engineering, evaluate the resume based on the given job description. Assign a percentage match based on the job description and the resume. resume: {text} description: {jd} """, "What are the missing keywords?": """ As a skilled ATS with a deep understanding of the tech field, software engineering, data science, data analysis, and big data engineering, evaluate the resume based on the given job description. Identify the missing keywords in the resume in concise, bullet points. resume: {text} description: {jd} """, "Can you summarize the profile?": """ As a skilled ATS with a deep understanding of the tech field, software engineering, data science, data analysis, and big data engineering, evaluate the resume based on the given job description. Provide a concise summary of the profile. resume: {text} description: {jd} """ } # app st.title("Smart ATS") st.sidebar.title("Job Description and Resume") # Job Description input jd = st.sidebar.text_area("Paste the Job Description", help="Enter the job description for the position you are applying for.") # Resume upload uploaded_file = st.sidebar.file_uploader("Upload Your Resume", type="pdf", help="Please upload your resume in PDF format.") resume_text = input_pdf_text(uploaded_file) # Pre-written questions st.sidebar.subheader("Quick Questions") questions = [ "What needs to improve?", "How well does my resume match the job description?", "What are the missing keywords?", "Can you summarize the profile?" ] selected_question = st.sidebar.radio("Choose a question:", questions) # Custom question input custom_question = st.text_input("Ask a custom question:", help="Enter any custom question related to your resume and job description.") # Submit button for custom question custom_submit = st.button("Reply") # Function to display formatted response def display_response(response): st.subheader("According to ATS:") formatted_response = format_response(response) st.markdown(formatted_response, unsafe_allow_html=True) def format_response(response): lines = response.split("\n") html_list = "