Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from parser import parse_resume
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
def process_input(job_description, *resumes):
|
| 6 |
+
resumes = [r for r in resumes if r and r.strip() != ""] # Remove empty
|
| 7 |
+
if not job_description.strip() or not resumes:
|
| 8 |
+
return "Please provide both job description and at least one resume."
|
| 9 |
+
|
| 10 |
+
thinking, results = parse_resume(job_description, resumes)
|
| 11 |
+
# formatted_output = f""
|
| 12 |
+
return thinking, json.loads(results)
|
| 13 |
+
|
| 14 |
+
# results = zip(*parse_resume(job_description, resumes))
|
| 15 |
+
# formatted_output = ""
|
| 16 |
+
# for i, (resume, score) in enumerate(results, 1):
|
| 17 |
+
# formatted_output += f"Resume #{i}:\nScore: {score:.2f}\nResume Snippet: {resume[:200]}...\n\n-------\n\n"
|
| 18 |
+
# return formatted_output
|
| 19 |
+
|
| 20 |
+
# UI definition
|
| 21 |
+
with gr.Blocks() as demo:
|
| 22 |
+
gr.Markdown("## π Resume Ranking System")
|
| 23 |
+
|
| 24 |
+
resumes_list = []
|
| 25 |
+
|
| 26 |
+
with gr.Row():
|
| 27 |
+
|
| 28 |
+
resume_count = gr.State(2)
|
| 29 |
+
|
| 30 |
+
with gr.Column():
|
| 31 |
+
@gr.render(inputs=resume_count)
|
| 32 |
+
def render_count(count):
|
| 33 |
+
for i in range(count):
|
| 34 |
+
name = gr.Textbox(
|
| 35 |
+
lines=1,
|
| 36 |
+
placeholder=f"Category #{i+1} name",
|
| 37 |
+
label=f"Name #{i+1}"
|
| 38 |
+
)
|
| 39 |
+
data_type = gr.Textbox(
|
| 40 |
+
lines=1,
|
| 41 |
+
placeholder=f"Category #{i+1} data type",
|
| 42 |
+
label=f"Data Type #{i+1}"
|
| 43 |
+
)
|
| 44 |
+
desc = gr.Textbox(
|
| 45 |
+
lines=1,
|
| 46 |
+
placeholder=f"Category #{i+1} description",
|
| 47 |
+
label=f"Description #{i+1}"
|
| 48 |
+
)
|
| 49 |
+
resumes_list.append(
|
| 50 |
+
{"name":name, "type":data_type, "description":desc}
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
submit_btn.click(
|
| 54 |
+
fn=process_input,
|
| 55 |
+
inputs=[job_description] + resumes_list,
|
| 56 |
+
outputs=[thinking_output, output]
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
# @gr.render(inputs=input_text)
|
| 60 |
+
# def add_resume():
|
| 61 |
+
# new_input = gr.Textbox(
|
| 62 |
+
# lines=6,
|
| 63 |
+
# placeholder=f"Paste resume #{len(resumes_list)+1} here...",
|
| 64 |
+
# label=f"Resume #{len(resumes_list)+1}"
|
| 65 |
+
# )
|
| 66 |
+
# resumes_list.append(new_input)
|
| 67 |
+
# return resumes_group.update(visible=True)
|
| 68 |
+
|
| 69 |
+
add_resume_btn = gr.Button("β Add Another Resume")
|
| 70 |
+
add_resume_btn.click(lambda x: x + 1, resume_count, resume_count)
|
| 71 |
+
|
| 72 |
+
with gr.Column():
|
| 73 |
+
job_description = gr.Textbox(
|
| 74 |
+
lines=8,
|
| 75 |
+
placeholder="Paste Resume here...",
|
| 76 |
+
label="Job Description"
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
# output = gr.Textbox(
|
| 80 |
+
# lines=10,
|
| 81 |
+
# label="JSON Result",
|
| 82 |
+
# interactive=False
|
| 83 |
+
# )
|
| 84 |
+
output = gr.JSON(show_indices=True)
|
| 85 |
+
thinking_output = gr.Textbox(
|
| 86 |
+
lines=10,
|
| 87 |
+
label="Thinking Result",
|
| 88 |
+
interactive=False
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
submit_btn = gr.Button("π Rank Resumes")
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
# add_resume_btn.click(add_resume, outputs=resumes_group)
|
| 95 |
+
# add_resume_btn.click(lambda x: x + 1, resume_count, resume_count)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
demo.launch()
|