cdcvd commited on
Commit
75bc0c6
·
verified ·
1 Parent(s): a22d292

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -0
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import os
4
+ import docx2txt
5
+ import PyPDF2 as pdf
6
+
7
+
8
+
9
+
10
+ def generate_response_from_jabir(resume_text, job_description):
11
+ base_url = "https://api.jabirproject.org/generate"
12
+ headers = {"apikey": os.getenv("7471142a-deb4-4a70-8ee3-6603e21bcc1d")}
13
+ input_prompt_template = """
14
+ As an experienced Applicant Tracking System (ATS) analyst,
15
+ with profound knowledge in technology, software engineering, data science,
16
+ and big data engineering, your role involves evaluating resumes against job descriptions.
17
+ Recognizing the competitive job market, provide top-notch assistance for resume improvement.
18
+ Your goal is to analyze the resume against the given job description,
19
+ assign a percentage match based on key criteria, and pinpoint missing keywords accurately.
20
+ resume:{text}
21
+ description:{job_description}
22
+ I want the response in one single string having the structure
23
+ {{"Job Description Match":"%","Missing Keywords":"","Candidate Summary":"","Experience":""}}
24
+ """
25
+ prompt = input_prompt_template.format(text=resume_text, job_description=job_description)
26
+ data = {
27
+ "messages": [{"role": "user", "content": prompt}]
28
+ }
29
+ response = requests.post(base_url, headers=headers, json=data)
30
+
31
+ if response.ok:
32
+ response_text = response.json()["choices"][0]["message"]["content"]
33
+ match_percentage_str = response_text.split('"Job Description Match":"')[1].split('"')[0]
34
+ match_percentage = float(match_percentage_str.rstrip('%'))
35
+
36
+ if match_percentage >= 80:
37
+ recommendation = "Move forward with hiring"
38
+ else:
39
+ recommendation = "Not a Match"
40
+
41
+ return response_text, recommendation
42
+ else:
43
+ return f"Error: {response.status_code}, {response.text}", None
44
+
45
+ def extract_text_from_file(uploaded_file):
46
+ if uploaded_file.name.endswith('.pdf'):
47
+ pdf_reader = pdf.PdfReader(uploaded_file)
48
+ text_content = ""
49
+ for page in pdf_reader.pages:
50
+ text_content += str(page.extract_text())
51
+ return text_content
52
+ elif uploaded_file.name.endswith('.docx'):
53
+ return docx2txt.process(uploaded_file)
54
+ else:
55
+ return "Unsupported file format"
56
+
57
+ def process_file(uploaded_file, job_description):
58
+ if uploaded_file is not None:
59
+ resume_text = extract_text_from_file(uploaded_file)
60
+ return generate_response_from_jabir(resume_text, job_description)
61
+ else:
62
+ return "No file uploaded", None
63
+
64
+ iface = gr.Interface(
65
+ fn=process_file,
66
+ inputs=[gr.Textbox(lines=10, label="resume ") ,gr.Textbox(lines=10, label="Job Description")],
67
+ outputs=[gr.Textbox(label="ATS Evaluation Result"), gr.Textbox(label="Recommendation")],
68
+ title="Intelligent ATS-Enhance Your Resume ATS"
69
+ )
70
+
71
+ iface.launch()