File size: 1,897 Bytes
75bc0c6
683d9b9
75bc0c6
ae96c08
75bc0c6
683d9b9
ae96c08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75bc0c6
683d9b9
75bc0c6
683d9b9
75bc0c6
 
683d9b9
75bc0c6
ae96c08
75bc0c6
 
 
 
 
683d9b9
 
 
 
 
 
 
 
 
75bc0c6
 
683d9b9
 
ae96c08
38c866d
683d9b9
 
 
75bc0c6
 
 
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
import gradio as gr
import openai
import os
import fitz  # PyMuPDF

# Set OpenAI API key
openai.api_key = os.getenv("sk-1E6ExsyFb-cdU8jPNDP1dsEq_ra_bazU-EXQZQ86pJT3BlbkFJ4zURsV0t--3qNM7A-P57NUqZIBosrL7POwzpjR5EQA")

def extract_text_from_pdf(pdf_file):
    # Open the PDF file
    document = fitz.open(pdf_file)
    text = ""
    # Extract text from each page
    for page_num in range(len(document)):
        page = document.load_page(page_num)
        text += page.get_text()
    return text

def evaluate_resume(pdf_file, job_description):
    # Extract text from PDF
    resume_text = extract_text_from_pdf(pdf_file)

    prompt = f"""
    As an experienced Applicant Tracking System (ATS) analyst,
    with profound knowledge in technology, software engineering, data science,
    and big data engineering, your role involves evaluating resumes against job descriptions.
    Recognizing the competitive job market, provide top-notch assistance for resume improvement.
    Your goal is to analyze the resume against the given job description,
    assign a percentage match based on key criteria, and pinpoint missing keywords accurately.
    resume:{resume_text}
    description:{job_description}
    I want the response in one single string having the structure
    {{"Job Description Match":"%","Missing Keywords":"","Candidate Summary":"","Experience":""}}
    """
    
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": prompt}
        ]
    )
    
    return response.choices[0].message['content']

iface = gr.Interface(
    fn=evaluate_resume,
    inputs=[
        gr.File(label="Upload Resume PDF"),
        gr.Textbox(lines=10, label="Job Description")
    ],
    outputs="text",
    title="Resume Evaluator"
)

iface.launch()