File size: 3,852 Bytes
32fc8f1
479320e
32fc8f1
a79d5c0
 
479320e
a79d5c0
32fc8f1
a79d5c0
32fc8f1
a79d5c0
 
 
 
 
 
32fc8f1
a79d5c0
32fc8f1
a79d5c0
 
 
 
e8417b8
 
 
 
a79d5c0
 
 
e8417b8
 
 
 
a79d5c0
e8417b8
f91f19f
ca9c2b2
a79d5c0
3c1fa35
a79d5c0
 
 
 
 
 
479320e
32fc8f1
479320e
 
32fc8f1
 
 
479320e
 
 
32fc8f1
1e74f1e
a79d5c0
 
479320e
a79d5c0
 
ec7518a
a79d5c0
 
 
479320e
a79d5c0
 
 
479320e
a79d5c0
 
 
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
import os
import streamlit as st
from dotenv import load_dotenv
import fitz  # PyMuPDF for handling PDFs
import openai

# Load environment variables and configure OpenAI API key
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")

def extract_text_from_pdf(upload_file):
    """Extract text from a PDF file using PyMuPDF (fitz)."""
    doc = fitz.open(stream=upload_file.read(), filetype="pdf")
    text = ""
    for page in doc:
        text += page.get_text("text")
    doc.close()
    return text

def get_openai_response(job_description, resume_text, prompt_type):
    """Send a prompt to the OpenAI API including both job description and resume text, and return the response."""
    if prompt_type == "evaluation":
        prompt = f"""
        As an experienced Technical Human Resource Manager, you have been tasked with reviewing a candidate's resume in comparison to a specific job description. Below, you will find both the job description and the resume text. Please read through them carefully and provide your professional evaluation.
        Job Description:{job_description}
        Resume Text:{resume_text}
        Based on your expertise, assess how well the candidate's profile aligns with the requirements and expectations of the role. Please highlight the strengths of the applicant that are most relevant to the job, as well as any weaknesses or areas where the candidate does not meet the job requirements. Offer insights into the suitability of the candidate for the position and any recommendations for areas of improvement or further development.
        """
    elif prompt_type == "match_percentage":
        prompt = f"""
        As a skilled ATS scanner with a deep understanding of computer science, tech jobs, and ATS functionality, you are tasked with evaluating a candidate's resume against a specific job description provided below. Your analysis should quantify how well the candidate's profile matches the job requirements.
        Job Description:{job_description}
        Resume Text:{resume_text}
        Please calculate the percentage match between the resume and the job description, indicating the degree to which the candidate meets the job requirements. Begin your response with the percentage match, followed by any critical keywords or qualifications that are missing from the resume. Conclude with your final thoughts on the applicant's suitability for the position, considering the match analysis and any areas where the resume could be improved to better align with the job description.
        """
        
    response = openai.completions.create(
      model="gpt-3.5-turbo-instruct", 
      prompt=prompt,
      temperature=0.7,
      max_tokens=1024,  # Adjusted to allow for more detailed responses
      top_p=1.0,
      frequency_penalty=0.0,
      presence_penalty=0.0
    )
    return response.choices[0].text.strip()

# Streamlit UI setup
st.set_page_config(page_title="Resume Parser")
st.header("Mock ATS")

# User inputs
input_text = st.text_area("Paste the job description here:", key="input")
uploaded_file = st.file_uploader("Upload your resume (only PDFs are supported)...", type="pdf")

if uploaded_file is not None:
    st.write("Resume uploaded successfully.")
 
submit1 = st.button("Tell me about the resume")
submit2 = st.button("Percentage match with the job description")

if uploaded_file is not None:
    resume_text = extract_text_from_pdf(uploaded_file)

    if submit1:
        response = get_openai_response(input_text, resume_text, "evaluation")
        st.subheader("The Response is:")
        st.write(response)
    elif submit2:
        response = get_openai_response(input_text, resume_text, "match_percentage")
        st.subheader("The Response is:")
        st.write(response)
else:
    if submit1 or submit2:
        st.error("Please upload the resume.")