-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
82 lines (63 loc) · 2.49 KB
/
app.py
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
import streamlit as st
import openai
import os
import PyPDF2 as pdf
from dotenv import load_dotenv
import json
load_dotenv()
st.set_page_config(
page_title="Smart ATS",
page_icon="👨💼",
layout="centered",
)
API_KEY = os.getenv("OPENAI_API_KEY")
if not API_KEY:
st.error("Please enter your OpenAI API Key.")
st.stop()
openai.api_key = API_KEY
def get_gpt4_response(prompt):
response = openai.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
],
max_tokens=1500,
n=1,
stop=None,
temperature=0.5,
)
return response.choices[0].message.content.strip()
def input_pdf_text(uploaded_file):
reader = pdf.PdfReader(uploaded_file)
text = ""
for page in range(len(reader.pages)):
page = reader.pages[page]
text += str(page.extract_text())
return text
input_prompt = """
Hey Act Like a very experienced ATS (Application Tracking System)with extensive experience in evaluating resumes in the tech field,
including, software engineering, macine learning, artificial intelligence,
data science, data analyst and big data engineering.
Your task is to evaluate the resume against the given job description.
You must consider the job market is very competitive and you should provide the
best assistance for improving the resumes. Assess the match percentage between the resume and the job description and the missing keywords with high accuracy also in Candidacy,
provide the skills that are there in the resume which are different from the job description and also highlight the skills that the employer is looking for and are not in the resume
resume:{text}
description:{jd}
I want the response in one single string having the structure
{{"JD Match":"%","MissingKeywords":[],"Profile Summary":"", "Candidacy":""}}
"""
st.title("Resume Matcher ATS")
jd = st.text_area("Paste the Job Description")
uploaded_file = st.file_uploader("Upload Your Resume", type="pdf", help="Please upload the PDF")
submit = st.button("Submit")
if submit:
if uploaded_file is not None:
text = input_pdf_text(uploaded_file)
print('done')
response = get_gpt4_response(input_prompt.format(text=text, jd=jd))
st.subheader("Response:")
parsed_response = json.loads(response)
for key, value in parsed_response.items():
st.write(f"**{key}:** {value}")