Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,71 +1,42 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
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:{
|
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 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
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=
|
66 |
-
inputs=[
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
69 |
)
|
70 |
|
71 |
iface.launch()
|
|
|
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,
|
12 |
and big data engineering, your role involves evaluating resumes against job descriptions.
|
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":""}}
|
20 |
"""
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
response = openai.ChatCompletion.create(
|
23 |
+
model="gpt-3.5-turbo",
|
24 |
+
messages=[
|
25 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
26 |
+
{"role": "user", "content": prompt}
|
27 |
+
]
|
28 |
+
)
|
29 |
+
|
30 |
+
return response.choices[0].message['content']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
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",
|
39 |
+
title="Resume Evaluator"
|
40 |
)
|
41 |
|
42 |
iface.launch()
|