TalentFinderAI / app.py
rajeshthangaraj1's picture
Create app.py
b4ab766 verified
raw
history blame
2.47 kB
import streamlit as st
import google.generativeai as genai
import os
import PyPDF2 as pdf
from dotenv import load_dotenv
load_dotenv()
genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
def get_gemeni_response(input_text):
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content(input_text)
return response.text
def input_pdf_text(upload_file):
reader = pdf.PdfReader(upload_file)
text = ""
for page in range(len(reader.pages)):
page_text = reader.pages[page].extract_text()
text += str(page_text)
return text
# Prompt engineering
input_prompt = """
hey Act like a skilled or very experienced ATS (Application Tracking System) with a deep understanding of tech field, software engineering,
data science, data analytics, and big data engineering. Your task is to evaluate the resume based on the given job description. You must
consider the job market is very competitive and provide the best assistance for improving the resume. Assign the percentage
Matching based on JD (Job Description) and the missing keywords with high accuracy.
resume: {text}
description: {jd}
I want the response in a structured JSON format like this:
{{"JD Match":"%", "MissingKeywords":[], "Profile Summary":""}}
"""
# Streamlit app setup
st.title('Smart ATS')
st.text("Improve your Resume ATS")
jd = st.text_area("Paste the Job Description")
uploaded_file = st.file_uploader("Upload your Resume", type="pdf", help="Please upload your resume in PDF format")
submit = st.button("Submit")
if submit:
if uploaded_file is not None:
text = input_pdf_text(uploaded_file)
response = get_gemeni_response(input_prompt.format(text=text, jd=jd))
try:
# Parse the response into a dictionary
response_dict = eval(response) # Be cautious with eval; use safer alternatives if possible
# Display structured output
st.subheader("Job Description Match")
st.write(f"{response_dict['JD Match']}")
st.subheader("Missing Keywords")
st.write(", ".join(response_dict["MissingKeywords"]))
st.subheader("Profile Summary")
st.text(response_dict["Profile Summary"])
except Exception as e:
st.error("Error parsing response. Check the response format.")
st.write(response) # Display raw response for debugging
else:
st.warning("Please upload your resume.")