Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from parser import parse_resume | |
| def process_input(job_description, resumes): | |
| # resumes = [r for r in resumes if r and r.strip() != ""] # Remove empty | |
| if not job_description.strip() or not resumes: | |
| return "Please provide both job description and at least one resume." | |
| print("[CATEGORIES]", resumes) | |
| thinking, results = parse_resume(job_description, resumes) | |
| return thinking, results | |
| # results = zip(*parse_resume(job_description, resumes)) | |
| # formatted_output = "" | |
| # for i, (resume, score) in enumerate(results, 1): | |
| # formatted_output += f"Resume #{i}:\nScore: {score:.2f}\nResume Snippet: {resume[:200]}...\n\n-------\n\n" | |
| # return formatted_output | |
| initial_parsing = [ | |
| {"name":"education", "type":"List[str]","description":"attended school, university, and other education programs"}, | |
| {"name":"experience", "type":"float", "description":"years of experience"}, | |
| {"name":"skills", "type":"List[str]", "description":"list of skills"}, | |
| {"name":"name", "type":"str", "description":"name of the person"}, | |
| {"name":"location", "type":"str", "description":"location of the person"}, | |
| {"name":"email", "type":"str", "description":"email of the person"}, | |
| {"name":"websites", "type":"List[str]", "description":"urls related of the person"}, | |
| {"name":"certifications", "type":"List[str]", "description":"list of certifications"}, | |
| {"name":"languages", "type":"List[str]", "description":"list of languages"}, | |
| {"name":"projects", "type":"List[str]", "description":"list of projects"}, | |
| {"name":"note", "type":"str", "description":"additional note which highlight the best or uniqueness of the person"} | |
| ] | |
| def update_json(data, name, data_type, desc): | |
| data.append( | |
| {"name":name, "type":data_type, "description":desc} | |
| ) | |
| return data | |
| # UI definition | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## π Resume Ranking System") | |
| resumes_list = [] | |
| with gr.Row(): | |
| resume_count = gr.State(2) | |
| with gr.Column(): | |
| def render_count(count): | |
| for i in range(count): | |
| name = gr.Textbox( | |
| lines=1, | |
| placeholder=f"Category #{i+1} name", | |
| label=f"Name #{i+1}" | |
| ) | |
| data_type = gr.Textbox( | |
| lines=1, | |
| placeholder=f"Category #{i+1} data type", | |
| label=f"Data Type #{i+1}" | |
| ) | |
| desc = gr.Textbox( | |
| lines=1, | |
| placeholder=f"Category #{i+1} description", | |
| label=f"Description #{i+1}" | |
| ) | |
| json_display = gr.JSON(value=initial_parsing, label="Parsing Categories") | |
| update_json_button = gr.Button("Update Parsing") | |
| update_json_button.click(update_json, inputs=[json_display, name, data_type, desc], outputs=json_display) | |
| # resumes_list.append( | |
| # {"name":name, "type":data_type, "description":desc} | |
| # ) | |
| # resumes_list.append(name) | |
| # resumes_list.append(data_type) | |
| # resumes_list.append(desc) | |
| submit_btn.click( | |
| fn=process_input, | |
| inputs=[job_description, json_display], | |
| outputs=[thinking_output, output] | |
| ) | |
| # @gr.render(inputs=input_text) | |
| # def add_resume(): | |
| # new_input = gr.Textbox( | |
| # lines=6, | |
| # placeholder=f"Paste resume #{len(resumes_list)+1} here...", | |
| # label=f"Resume #{len(resumes_list)+1}" | |
| # ) | |
| # resumes_list.append(new_input) | |
| # return resumes_group.update(visible=True) | |
| add_resume_btn = gr.Button("β Add Another Category") | |
| add_resume_btn.click(lambda x: x + 1, resume_count, resume_count) | |
| with gr.Column(): | |
| job_description = gr.Textbox( | |
| lines=8, | |
| placeholder="Paste Resume here...", | |
| label="Job Description" | |
| ) | |
| # output = gr.Textbox( | |
| # lines=10, | |
| # label="JSON Result", | |
| # interactive=False | |
| # ) | |
| output = gr.JSON(show_indices=True) | |
| thinking_output = gr.Textbox( | |
| lines=10, | |
| label="Thinking Result", | |
| interactive=False | |
| ) | |
| submit_btn = gr.Button("π Parse Resume / CV") | |
| # add_resume_btn.click(add_resume, outputs=resumes_group) | |
| # add_resume_btn.click(lambda x: x + 1, resume_count, resume_count) | |
| demo.launch() | |