File size: 4,837 Bytes
5302799
 
b89bba2
66bf5cc
 
5302799
 
 
 
66bf5cc
c9c2072
 
97ad829
66bf5cc
c9052ff
 
66bf5cc
 
 
 
 
 
 
 
 
 
 
 
c9c2072
66bf5cc
 
 
5302799
 
66bf5cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9c2072
66bf5cc
 
5302799
 
66bf5cc
 
 
c9c2072
66bf5cc
 
 
 
 
 
c9c2072
66bf5cc
c9c2072
 
 
 
5302799
 
66bf5cc
 
 
 
 
 
 
 
c9c2072
66bf5cc
 
5302799
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66bf5cc
5302799
66bf5cc
5302799
 
 
 
 
c9c2072
 
5302799
 
 
 
 
 
 
 
 
 
c9c2072
67681cb
 
 
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
115
116
117
118
119
120
121
122
123
124
125
126
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)
    # Implement ATS-friendly checker logic using LLM
    system_message = "Evaluate the following resume for ATS-friendliness and provide a score and 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
    
    score = response.split("\n")[0].split(":")[-1].strip()
    feedback = "\n".join(response.split("\n")[1:])
    return score, 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)
    # Implement resume match checker logic using LLM
    system_message = "Compare the following resume with the job description and provide a match score."
    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

    match_score = response.split(":")[-1].strip()
    return match_score

def resume_quality_score(file):
    resume_text = extract_text_from_pdf(file)
    # Implement resume quality scoring logic using LLM
    system_message = "Evaluate the following resume for overall quality and provide a score and interpretation."
    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

    score_lines = response.split("\n")
    quality_score = score_lines[0].split(":")[-1].strip()
    interpretation = "\n".join(score_lines[1:])
    return quality_score, interpretation

def text_to_overleaf(resume_text):
    # Implement the conversion to Overleaf code using LLM
    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)")
            score = gr.Number(label="ATS Score", interactive=False)
            feedback = gr.Textbox(label="Feedback", interactive=False)
        resume.upload(ats_friendly_checker, resume, [score, 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")
            match_score = gr.Number(label="Match Score", interactive=False)
        gr.Button("Check Match").click(resume_match_checker, [resume, job_url], match_score)
    
    with gr.Tab("Resume Quality Score"):
        with gr.Row():
            resume = gr.File(label="Upload your Resume (PDF)")
            quality_score = gr.Number(label="Quality Score", interactive=False)
            interpretation = gr.Textbox(label="Interpretation", interactive=False)
        resume.upload(resume_quality_score, resume, [quality_score, 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)
        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)