jonathanjordan21 commited on
Commit
2758618
Β·
verified Β·
1 Parent(s): c3fab11

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -0
app.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ # from embeddings import rank_jobs
3
+
4
+ # Function to wrap the existing rank_resume
5
+ def process_input(job_description, *resumes):
6
+ print("[JOB DESC]", job_description)
7
+ print("[RESUMES]", resumes)
8
+ resumes = [r for r in resumes if r and r.strip() != ""] # Remove empty
9
+ if not job_description.strip() or not resumes:
10
+ return "Please provide both resume and at least one job description."
11
+
12
+ results = zip(*rank_jobs(job_description, resumes))
13
+ formatted_output = ""
14
+ for i, (resume, score) in enumerate(results, 1):
15
+ formatted_output += f"Job #{i}:\nScore: {score:.2f}\nJob Description Snippet: {resume[:200]}...\n\n-------\n\n"
16
+ return formatted_output
17
+
18
+
19
+
20
+ resumes = [
21
+
22
+ ]
23
+
24
+ def add_resume_count(*resumes):
25
+ resumes = [r for r in resumes if r and r.strip() != ""]
26
+ return resumes
27
+
28
+
29
+ # UI definition
30
+ with gr.Blocks() as demo:
31
+ gr.Markdown("## πŸ“ Job Suggestion")
32
+
33
+ resumes_list = []
34
+
35
+ with gr.Row():
36
+
37
+ resume_count = gr.State([
38
+
39
+ ])
40
+
41
+ with gr.Column():
42
+ @gr.render(inputs=resume_count)
43
+ def render_count(count):
44
+ # print("[COUNT]", count)
45
+ # print("[RESUME LIST]", resumes_list)
46
+ for i in range(len(count)):
47
+ resume_input = gr.Textbox(
48
+ lines=6,
49
+ placeholder=f"Paste job description #{i+1} here...",
50
+ label=f"Job #{i+1}",
51
+ value=count[i]
52
+ )
53
+ resumes_list.append(resume_input)
54
+
55
+ submit_btn.click(
56
+ fn=process_input,
57
+ inputs=[job_description] + resumes_list,
58
+ outputs=output
59
+ )
60
+
61
+ # @gr.render(inputs=input_text)
62
+ # def add_resume():
63
+ # new_input = gr.Textbox(
64
+ # lines=6,
65
+ # placeholder=f"Paste resume #{len(resumes_list)+1} here...",
66
+ # label=f"Resume #{len(resumes_list)+1}"
67
+ # )
68
+ # resumes_list.append(new_input)
69
+ # return resumes_group.update(visible=True)
70
+
71
+ add_resume_btn = gr.Button("βž• Add Job Description")
72
+ add_resume_btn.click(add_resume_count, resumes_list, resume_count)
73
+
74
+ with gr.Column():
75
+ job_description = gr.Textbox(
76
+ lines=8,
77
+ placeholder="Paste Job Description here...",
78
+ label="Job Description"
79
+ )
80
+
81
+ output = gr.Textbox(
82
+ lines=10,
83
+ label="Job Suggestion Result",
84
+ interactive=False
85
+ )
86
+ submit_btn = gr.Button("πŸš€ Job Suggestion")
87
+
88
+ demo.launch()