Spaces:
Running
Running
File size: 4,382 Bytes
5302799 b89bba2 66bf5cc 5302799 66bf5cc c9c2072 97ad829 66bf5cc c9052ff 66bf5cc ed7680f 66bf5cc c9c2072 66bf5cc ed7680f 5302799 66bf5cc ed7680f 66bf5cc c9c2072 66bf5cc ed7680f 5302799 66bf5cc ed7680f 66bf5cc c9c2072 66bf5cc ed7680f 5302799 66bf5cc c9c2072 66bf5cc 5302799 ed7680f 5302799 66bf5cc ed7680f 5302799 ed7680f 5302799 ed7680f 5302799 c9c2072 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
import gradio as gr
from huggingface_hub import InferenceClient
from PyPDF2 import PdfReader
import requests
from bs4 import BeautifulSoup
# Initialize the Inference Client
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
def extract_text_from_pdf(file):
if file is None:
return ""
reader = PdfReader(file)
text = ""
for page in reader.pages:
text += page.extract_text()
return text
def ats_friendly_checker(file):
resume_text = extract_text_from_pdf(file)
system_message = "Evaluate the following resume for ATS-friendliness and provide feedback."
message = resume_text
response = client.chat_completion(
[{"role": "system", "content": system_message}, {"role": "user", "content": message}],
max_tokens=512,
temperature=0.7,
top_p=0.95
).choices[0].message.content
feedback = response
return feedback
def scrape_job_description(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
job_description = soup.get_text(separator=" ", strip=True)
return job_description
def resume_match_checker(file, job_url):
resume_text = extract_text_from_pdf(file)
job_description = scrape_job_description(job_url)
system_message = "Compare the following resume with the job description and provide feedback."
message = f"Resume: {resume_text}\n\nJob Description: {job_description}"
response = client.chat_completion(
[{"role": "system", "content": system_message}, {"role": "user", "content": message}],
max_tokens=512,
temperature=0.7,
top_p=0.95
).choices[0].message.content
feedback = response
return feedback
def resume_quality_score(file):
resume_text = extract_text_from_pdf(file)
system_message = "Evaluate the following resume for overall quality and provide feedback."
message = resume_text
response = client.chat_completion(
[{"role": "system", "content": system_message}, {"role": "user", "content": message}],
max_tokens=512,
temperature=0.7,
top_p=0.95
).choices[0].message.content
interpretation = response
return interpretation
def text_to_overleaf(resume_text):
system_message = "Convert the following resume text to Overleaf code."
message = resume_text
response = client.chat_completion(
[{"role": "system", "content": system_message}, {"role": "user", "content": message}],
max_tokens=512,
temperature=0.7,
top_p=0.95
).choices[0].message.content
overleaf_code = response
return overleaf_code
# Define the Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# Resume Enhancement Tool\nEnhance your resume with the following features.")
with gr.Tab("ATS-Friendly Checker"):
with gr.Row():
resume = gr.File(label="Upload your Resume (PDF)")
feedback = gr.Textbox(label="Feedback", interactive=False, lines=15, max_lines=50) # Increase lines to fill the page
resume.upload(ats_friendly_checker, resume, feedback)
with gr.Tab("Resume Match Checker"):
with gr.Row():
resume = gr.File(label="Upload your Resume (PDF)")
job_url = gr.Textbox(label="Job Description URL")
feedback = gr.Textbox(label="Feedback", interactive=False, lines=15, max_lines=50) # Increase lines to fill the page
gr.Button("Check Match").click(resume_match_checker, [resume, job_url], feedback)
with gr.Tab("Resume Quality Score"):
with gr.Row():
resume = gr.File(label="Upload your Resume (PDF)")
interpretation = gr.Textbox(label="Interpretation", interactive=False, lines=15, max_lines=50) # Increase lines to fill the page
resume.upload(resume_quality_score, resume, interpretation)
with gr.Tab("Text to Overleaf Code"):
with gr.Row():
resume_text = gr.Textbox(label="Resume Text")
overleaf_code = gr.Textbox(label="Overleaf Code", interactive=False, lines=15, max_lines=50) # Increase lines to fill the page
resume_text.submit(text_to_overleaf, resume_text, overleaf_code)
gr.Markdown("---\nBuilt with love by [Bahae Eddine HALIM](https://www.linkedin.com/in/halimbahae/)")
if __name__ == "__main__":
demo.launch(share=True)
|