Spaces:
Runtime error
Runtime error
File size: 5,786 Bytes
60ca601 077d7f9 60ca601 1585504 60ca601 1585504 60ca601 0580d9b 60ca601 e90152c 1585504 e90152c 1585504 60ca601 1585504 60ca601 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
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="CV PARSER")
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() |