halimbahae commited on
Commit
66bf5cc
·
verified ·
1 Parent(s): 5302799

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -50
app.py CHANGED
@@ -1,66 +1,86 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
 
 
3
 
4
  # Initialize the Inference Client
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
7
- def ats_friendly_checker(resume):
8
- # Implement the ATS-friendly checker logic here
9
- # For demonstration, we'll return a mock score and feedback
10
- score = 75 # Mock score
11
- feedback = "Your resume needs more keywords related to the job."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  return score, feedback
13
 
14
- def resume_match_checker(resume, job_description):
15
- # Implement the resume match logic here
16
- # For demonstration, we'll return a mock match score
17
- match_score = 80 # Mock match score
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  return match_score
19
 
20
- def resume_quality_score(resume):
21
- # Implement the resume quality scoring logic here
22
- # For demonstration, we'll return a mock quality score
23
- quality_score = 85 # Mock quality score
 
 
 
 
 
 
 
 
 
24
  return quality_score
25
 
26
  def text_to_overleaf(resume_text):
27
- # Implement the conversion to Overleaf code here
28
- # For demonstration, we'll return a mock Overleaf code
29
- overleaf_code = "Mock Overleaf Code"
 
 
 
 
 
 
 
 
30
  return overleaf_code
31
 
32
- def respond(
33
- message,
34
- history: list[tuple[str, str]],
35
- system_message,
36
- max_tokens,
37
- temperature,
38
- top_p,
39
- ):
40
- messages = [{"role": "system", "content": system_message}]
41
-
42
- for val in history:
43
- if val[0]:
44
- messages.append({"role": "user", "content": val[0]})
45
- if val[1]:
46
- messages.append({"role": "assistant", "content": val[1]})
47
-
48
- messages.append({"role": "user", "content": message})
49
-
50
- response = ""
51
-
52
- for message in client.chat_completion(
53
- messages,
54
- max_tokens=max_tokens,
55
- stream=True,
56
- temperature=temperature,
57
- top_p=top_p,
58
- ):
59
- token = message.choices[0].delta.content
60
-
61
- response += token
62
- yield response
63
-
64
  # Define the Gradio interface
65
  with gr.Blocks() as demo:
66
  gr.Markdown("# Resume Enhancement Tool\nEnhance your resume with the following features.")
@@ -75,9 +95,9 @@ with gr.Blocks() as demo:
75
  with gr.Tab("Resume Match Checker"):
76
  with gr.Row():
77
  resume = gr.File(label="Upload your Resume (PDF)")
78
- job_description = gr.Textbox(label="Job Description")
79
  match_score = gr.Number(label="Match Score", interactive=False)
80
- resume.upload(resume_match_checker, [resume, job_description], match_score)
81
 
82
  with gr.Tab("Resume Quality Score"):
83
  with gr.Row():
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ from PyPDF2 import PdfFileReader
4
+ import requests
5
+ from bs4 import BeautifulSoup
6
 
7
  # Initialize the Inference Client
8
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
10
+ def extract_text_from_pdf(file):
11
+ reader = PdfFileReader(file)
12
+ text = ""
13
+ for page in range(reader.getNumPages()):
14
+ text += reader.getPage(page).extract_text()
15
+ return text
16
+
17
+ def ats_friendly_checker(file):
18
+ resume_text = extract_text_from_pdf(file)
19
+ # Implement ATS-friendly checker logic using LLM
20
+ system_message = "Evaluate the following resume for ATS-friendliness and provide a score and feedback."
21
+ message = resume_text
22
+ response = client.chat_completion(
23
+ [{"role": "system", "content": system_message}, {"role": "user", "content": message}],
24
+ max_tokens=512,
25
+ temperature=0.7,
26
+ top_p=0.95
27
+ ).choices[0].message["content"]
28
+
29
+ score = response.split("\n")[0].split(":")[-1].strip()
30
+ feedback = "\n".join(response.split("\n")[1:])
31
  return score, feedback
32
 
33
+ def scrape_job_description(url):
34
+ response = requests.get(url)
35
+ soup = BeautifulSoup(response.text, 'html.parser')
36
+ job_description = soup.get_text(separator=" ", strip=True)
37
+ return job_description
38
+
39
+ def resume_match_checker(file, job_url):
40
+ resume_text = extract_text_from_pdf(file)
41
+ job_description = scrape_job_description(job_url)
42
+ # Implement resume match checker logic using LLM
43
+ system_message = "Compare the following resume with the job description and provide a match score."
44
+ message = f"Resume: {resume_text}\n\nJob Description: {job_description}"
45
+ response = client.chat_completion(
46
+ [{"role": "system", "content": system_message}, {"role": "user", "content": message}],
47
+ max_tokens=512,
48
+ temperature=0.7,
49
+ top_p=0.95
50
+ ).choices[0].message["content"]
51
+
52
+ match_score = response.split(":")[-1].strip()
53
  return match_score
54
 
55
+ def resume_quality_score(file):
56
+ resume_text = extract_text_from_pdf(file)
57
+ # Implement resume quality scoring logic using LLM
58
+ system_message = "Evaluate the following resume for overall quality and provide a score."
59
+ message = resume_text
60
+ response = client.chat_completion(
61
+ [{"role": "system", "content": system_message}, {"role": "user", "content": message}],
62
+ max_tokens=512,
63
+ temperature=0.7,
64
+ top_p=0.95
65
+ ).choices[0].message["content"]
66
+
67
+ quality_score = response.split(":")[-1].strip()
68
  return quality_score
69
 
70
  def text_to_overleaf(resume_text):
71
+ # Implement the conversion to Overleaf code using LLM
72
+ system_message = "Convert the following resume text to Overleaf code."
73
+ message = resume_text
74
+ response = client.chat_completion(
75
+ [{"role": "system", "content": system_message}, {"role": "user", "content": message}],
76
+ max_tokens=512,
77
+ temperature=0.7,
78
+ top_p=0.95
79
+ ).choices[0].message["content"]
80
+
81
+ overleaf_code = response
82
  return overleaf_code
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  # Define the Gradio interface
85
  with gr.Blocks() as demo:
86
  gr.Markdown("# Resume Enhancement Tool\nEnhance your resume with the following features.")
 
95
  with gr.Tab("Resume Match Checker"):
96
  with gr.Row():
97
  resume = gr.File(label="Upload your Resume (PDF)")
98
+ job_url = gr.Textbox(label="Job Description URL")
99
  match_score = gr.Number(label="Match Score", interactive=False)
100
+ gr.Button("Check Match").click(resume_match_checker, [resume, job_url], match_score)
101
 
102
  with gr.Tab("Resume Quality Score"):
103
  with gr.Row():