CV_2 / app.py
kilachei's picture
Upload 2 files
76222f7 verified
from dotenv import load_dotenv
load_dotenv()
import streamlit as st
import os
import io
import base64
from PIL import Image
import pdf2image
from PyPDF2 import PdfReader
import google.generativeai as genai
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import FAISS, Chroma
from langchain.chains.question_answering import load_qa_chain
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.prompts import PromptTemplate
from openai import OpenAI
client = OpenAI()
#read pdf
def get_pdf_text(pdf_docs):
text=""
for pdf in pdf_docs:
pdf_reader= PdfReader(pdf)
for page in pdf_reader.pages:
text+= page.extract_text()
return text
#divide pdf text into overlapping chunks
def get_text_chunks(text):
text_splitter = RecursiveCharacterTextSplitter(chunk_size = 30, chunk_overlap=5)
chunks = text_splitter.split_text(text)
return chunks
#convert chunks to embeddings
def get_vector_store(text_chunks):
embeddings = OpenAIEmbeddings()
vector_store = FAISS.from_texts(text_chunks, embedding=embeddings)
#vector stores can be stored locally or even in a database
vector_store.save_local("faiss_index")
def get_openai_response(prompt):
completion = client.chat.completions.create(
model="gpt-3.5-turbo", # or other available engines
messages=[
{"role": "user", "content": prompt}
]
)
return completion.choices[0].message.content
def main():
st.set_page_config(page_title="Personal ATS")
st.header("ATS Keyword Matching")
input_text_title = st.text_area("Job Title: ", key="inpu_title")
input_text_jd = st.text_area("Job Description: ", key="input_jd")
pdf_docs = st.file_uploader("Upload Resume (pdf)", accept_multiple_files=True)
submit1 = st.button("Resume evaluation against job role")
submit2 = st.button("Percentage Match")
submit3 = st.button("Ideal Resume")
input_prompt1 = """
You are an experienced Technical Human Resource Manager experienced in the field of {}, 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.
Resume: {}
Job Description: {}
"""
input_prompt2 = """
You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding in the field of {},
your task is to evaluate the resume against the provided job description. You should output first the percentage of match between the resume and
the job description, followed by keywords matching, keywords missing, specific changes for resume to reach matching percentage
of above 85 and lastly your final thoughts.
Resume: {}
Job Description: {}
"""
input_prompt3_alternate = """
You are an expert at making resumes for the job role of {}. Your task is to make an ideal resume for the job description I give you using ONLY the following three sections and then give me a keyword match percentage between the created resume and the job description at the end:
1. The skills section with comma separated technical tools and frameworks.
2. The work experience section with 3 job roles.
3. Projects section with six ADVANCED projects and you have to
make up your own projects from imagination that would use the same
tech stack specified in the job description with minimum overlap of tech stack between the projects.
Each project will have a project title followed by two bullet points.
First bullet point is the project description
and the second bullet point is the tech stack used to make the project.
You also have to give me exact value for keyword match percentage between the resume you created and the job description.
Job Description: {}
"""
input_prompt3 = """
Write a resume based on the following job description for the {} position and include bullet point achievements that show impact and metrics.
It should include ONLY these section:
1. The skills section with comma separated technical tools and frameworks.
2. The work experience section with 3 job roles.
3. Projects section with six ADVANCED projects. Each project will have a project title followed by two bullet points. First bullet point is the project description and the second bullet point is the tech stack used to make the project. Use numbers that show impact and metrics
Job description: {}
"""
if submit1:
if pdf_docs is not None:
pdf_content = get_pdf_text(pdf_docs)
prompt = input_prompt1.format(input_text_title, pdf_content, input_text_jd)
response = get_openai_response(prompt)
st.subheader("Response: ")
st.write(response)
else:
st.write("Please upload resume")
elif submit2:
if pdf_docs is not None:
pdf_content = get_pdf_text(pdf_docs)
prompt = input_prompt2.format(input_text_title, pdf_content, input_text_jd)
response = get_openai_response(prompt)
st.subheader("Response: ")
st.write(response)
else:
st.write("Please upload resume")
elif submit3:
if input_text_jd is not None:
pdf_content = get_pdf_text(pdf_docs)
prompt = input_prompt3.format(input_text_title, input_text_jd)
response = get_openai_response(prompt)
st.subheader("Response: ")
st.write(response)
else:
st.write("Please upload resume")
if __name__ == "__main__":
main()