Spaces:
Sleeping
Sleeping
Karthikeyan
commited on
Commit
·
b6894c3
1
Parent(s):
deddb30
Upload 3 files
Browse files- app.py +82 -0
- requirements.txt +3 -0
- style.css +25 -0
app.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import PyPDF2
|
3 |
+
import os
|
4 |
+
import openai
|
5 |
+
|
6 |
+
def extract_text_from_file(file_path):
|
7 |
+
# Get the file extension
|
8 |
+
file_extension = os.path.splitext(file_path)[1]
|
9 |
+
|
10 |
+
if file_extension == '.pdf':
|
11 |
+
with open(file_path, 'rb') as file:
|
12 |
+
# Create a PDF file reader object
|
13 |
+
reader = PyPDF2.PdfFileReader(file)
|
14 |
+
|
15 |
+
# Create an empty string to hold the extracted text
|
16 |
+
extracted_text = ""
|
17 |
+
|
18 |
+
# Loop through each page in the PDF and extract the text
|
19 |
+
for page_number in range(reader.getNumPages()):
|
20 |
+
page = reader.getPage(page_number)
|
21 |
+
extracted_text += page.extractText()
|
22 |
+
return extracted_text
|
23 |
+
|
24 |
+
elif file_extension == '.txt':
|
25 |
+
with open(file_path, 'r') as file:
|
26 |
+
# Just read the entire contents of the text file
|
27 |
+
return file.read()
|
28 |
+
|
29 |
+
else:
|
30 |
+
return "Unsupported file type"
|
31 |
+
|
32 |
+
def responce_from_ai(textjd, textcv):
|
33 |
+
resume = extract_text_from_file(textjd)
|
34 |
+
job_description = extract_text_from_file(textcv)
|
35 |
+
|
36 |
+
response = openai.Completion.create(
|
37 |
+
engine="text-davinci-003",
|
38 |
+
prompt=f"""Given the job description and the resume, assess the matching percentage and approximate percentage of the resume for the job.**Job Description:**{job_description}**Resume:**{resume}**Matching Assessment:**Based on an analysis of the resume and the job description,
|
39 |
+
the overall matching percentage is estimated to be approximately [insert approximate percentage here].
|
40 |
+
**Detailed Analysis:**
|
41 |
+
the result should be in this format:
|
42 |
+
matched percentage: [matching percentage]
|
43 |
+
reason : [reason for this result]
|
44 |
+
keywords : [matched key words from job_description and resume]""",
|
45 |
+
temperature=0,
|
46 |
+
max_tokens=100,
|
47 |
+
n=1,
|
48 |
+
stop=None,
|
49 |
+
)
|
50 |
+
generated_text = response.choices[0].text.strip()
|
51 |
+
return generated_text
|
52 |
+
|
53 |
+
def matching_percentage(job_description_path, resume_path):
|
54 |
+
|
55 |
+
job_description_path = job_description_path.name
|
56 |
+
resume_path = resume_path.name
|
57 |
+
|
58 |
+
generated_text = responce_from_ai(job_description_path, resume_path)
|
59 |
+
return generated_text
|
60 |
+
|
61 |
+
title = """<br><br><br><div style="text-align: center;max-width: 700px;">
|
62 |
+
<h1><a style="display:inline-block; margin-left: 1em; text-decoration:none; font-weight:bold;" >Syngenta </a> - Resume Matching</h1>
|
63 |
+
</p>"""
|
64 |
+
with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as app:
|
65 |
+
gr.HTML("""<center><img class="image" align="center" src="https://logos-download.com/wp-content/uploads/2016/06/Syngenta_logo.png" alt="Image" width="200" height="200"></center>""")
|
66 |
+
with gr.Row():
|
67 |
+
with gr.Column(elem_id="col-container"):
|
68 |
+
gr.HTML(title)
|
69 |
+
with gr.Row():
|
70 |
+
with gr.Column(scale=0.45, min_width=150, ):
|
71 |
+
jobDescription = gr.inputs.File(label="Job Description")
|
72 |
+
with gr.Column(scale=0.45, min_width=150):
|
73 |
+
resume = gr.inputs.File(label="Resume")
|
74 |
+
with gr.Column(scale=0.10, min_width=150):
|
75 |
+
find = gr.Button("Find")
|
76 |
+
with gr.Row():
|
77 |
+
with gr.Column(scale=1.0, min_width=150):
|
78 |
+
output = gr.outputs.Textbox(label="Matching Percentage")
|
79 |
+
|
80 |
+
find.click(matching_percentage, [jobDescription, resume], [output])
|
81 |
+
|
82 |
+
app.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
gradio
|
3 |
+
PyPDF2==2.12.1
|
style.css
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#col-container {
|
3 |
+
max-width: 600px;
|
4 |
+
margin-left: auto;
|
5 |
+
margin-right: auto;
|
6 |
+
}
|
7 |
+
|
8 |
+
#row-flex {
|
9 |
+
display: flex;
|
10 |
+
align-items: center;
|
11 |
+
justify-content: center;
|
12 |
+
}
|
13 |
+
a,
|
14 |
+
a:hover,
|
15 |
+
a:visited {
|
16 |
+
text-decoration-line: underline;
|
17 |
+
font-weight: 600;
|
18 |
+
color: #1f2937 !important;
|
19 |
+
}
|
20 |
+
|
21 |
+
.dark a,
|
22 |
+
.dark a:hover,
|
23 |
+
.dark a:visited {
|
24 |
+
color: #f3f4f6 !important;
|
25 |
+
}
|