cdcvd commited on
Commit
ae96c08
1 Parent(s): 683d9b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -1,11 +1,25 @@
1
  import gradio as gr
2
  import openai
3
  import os
 
4
 
5
  # Set OpenAI API key
6
- openai.api_key = os.getenv("OPENAI_API_KEY")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- def evaluate_resume(resume, job_description):
9
  prompt = f"""
10
  As an experienced Applicant Tracking System (ATS) analyst,
11
  with profound knowledge in technology, software engineering, data science,
@@ -13,7 +27,7 @@ def evaluate_resume(resume, job_description):
13
  Recognizing the competitive job market, provide top-notch assistance for resume improvement.
14
  Your goal is to analyze the resume against the given job description,
15
  assign a percentage match based on key criteria, and pinpoint missing keywords accurately.
16
- resume:{resume}
17
  description:{job_description}
18
  I want the response in one single string having the structure
19
  {{"Job Description Match":"%","Missing Keywords":"","Candidate Summary":"","Experience":""}}
@@ -32,7 +46,7 @@ def evaluate_resume(resume, job_description):
32
  iface = gr.Interface(
33
  fn=evaluate_resume,
34
  inputs=[
35
- gr.inputs.Textbox(lines=10, label="Resume"),
36
  gr.inputs.Textbox(lines=10, label="Job Description")
37
  ],
38
  outputs="text",
 
1
  import gradio as gr
2
  import openai
3
  import os
4
+ import fitz # PyMuPDF
5
 
6
  # Set OpenAI API key
7
+ openai.api_key = os.getenv("sk-1E6ExsyFb-cdU8jPNDP1dsEq_ra_bazU-EXQZQ86pJT3BlbkFJ4zURsV0t--3qNM7A-P57NUqZIBosrL7POwzpjR5EQA")
8
+
9
+ def extract_text_from_pdf(pdf_file):
10
+ # Open the PDF file
11
+ document = fitz.open(pdf_file)
12
+ text = ""
13
+ # Extract text from each page
14
+ for page_num in range(len(document)):
15
+ page = document.load_page(page_num)
16
+ text += page.get_text()
17
+ return text
18
+
19
+ def evaluate_resume(pdf_file, job_description):
20
+ # Extract text from PDF
21
+ resume_text = extract_text_from_pdf(pdf_file)
22
 
 
23
  prompt = f"""
24
  As an experienced Applicant Tracking System (ATS) analyst,
25
  with profound knowledge in technology, software engineering, data science,
 
27
  Recognizing the competitive job market, provide top-notch assistance for resume improvement.
28
  Your goal is to analyze the resume against the given job description,
29
  assign a percentage match based on key criteria, and pinpoint missing keywords accurately.
30
+ resume:{resume_text}
31
  description:{job_description}
32
  I want the response in one single string having the structure
33
  {{"Job Description Match":"%","Missing Keywords":"","Candidate Summary":"","Experience":""}}
 
46
  iface = gr.Interface(
47
  fn=evaluate_resume,
48
  inputs=[
49
+ gr.File(label="Upload Resume PDF"),
50
  gr.inputs.Textbox(lines=10, label="Job Description")
51
  ],
52
  outputs="text",