Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
import os | |
import docx2txt | |
import PyPDF2 as pdf | |
def generate_response_from_jabir(resume_text, job_description): | |
base_url = "https://api.jabirproject.org/generate" | |
headers = {"apikey": os.getenv("7471142a-deb4-4a70-8ee3-6603e21bcc1d")} | |
input_prompt_template = """ | |
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:{text} | |
description:{job_description} | |
I want the response in one single string having the structure | |
{{"Job Description Match":"%","Missing Keywords":"","Candidate Summary":"","Experience":""}} | |
""" | |
prompt = input_prompt_template.format(text=resume_text, job_description=job_description) | |
data = { | |
"messages": [{"role": "user", "content": prompt}] | |
} | |
response = requests.post(base_url, headers=headers, json=data) | |
if response.ok: | |
response_text = response.json()["choices"][0]["message"]["content"] | |
match_percentage_str = response_text.split('"Job Description Match":"')[1].split('"')[0] | |
match_percentage = float(match_percentage_str.rstrip('%')) | |
if match_percentage >= 80: | |
recommendation = "Move forward with hiring" | |
else: | |
recommendation = "Not a Match" | |
return response_text, recommendation | |
else: | |
return f"Error: {response.status_code}, {response.text}", None | |
def extract_text_from_file(uploaded_file): | |
if uploaded_file.name.endswith('.pdf'): | |
pdf_reader = pdf.PdfReader(uploaded_file) | |
text_content = "" | |
for page in pdf_reader.pages: | |
text_content += str(page.extract_text()) | |
return text_content | |
elif uploaded_file.name.endswith('.docx'): | |
return docx2txt.process(uploaded_file) | |
else: | |
return "Unsupported file format" | |
def process_file(uploaded_file, job_description): | |
if uploaded_file is not None: | |
resume_text = extract_text_from_file(uploaded_file) | |
return generate_response_from_jabir(resume_text, job_description) | |
else: | |
return "No file uploaded", None | |
iface = gr.Interface( | |
fn=process_file, | |
inputs=[gr.Textbox(lines=10, label="resume ") ,gr.Textbox(lines=10, label="Job Description")], | |
outputs=[gr.Textbox(label="ATS Evaluation Result"), gr.Textbox(label="Recommendation")], | |
title="Intelligent ATS-Enhance Your Resume ATS" | |
) | |
iface.launch() |