Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from embeddings import rank_jobs | |
| # Function to wrap the existing rank_jobs | |
| def process_input(job_description, *resumes): | |
| print("[JOB DESC]", job_description) | |
| print("[RESUMES]", 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 resume and at least one job description." | |
| results = zip(*rank_jobs(resumes, job_description)) | |
| formatted_output = "" | |
| for i, (resume, score) in enumerate(results, 1): | |
| formatted_output += f"Job #{i}:\nScore: {score:.2f}\nJob Description Snippet: {resume[:200]}...\n\n-------\n\n" | |
| return formatted_output | |
| # resumes = [ | |
| # ] | |
| def add_resume_count(*resumes): | |
| resumes = [r for r in resumes if r and r.strip() != ""] | |
| resumes.append("") | |
| print('[RESUMES]', resumes) | |
| return resumes | |
| # UI definition | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## π Job Suggestion") | |
| resumes_list = [] | |
| with gr.Row(): | |
| resume_count = gr.State([ | |
| "", "" | |
| ]) | |
| with gr.Column(): | |
| def render_count(count): | |
| # print("[COUNT]", count) | |
| # print("[RESUME LIST]", resumes_list) | |
| for i in range(len(count)): | |
| resume_input = gr.Textbox( | |
| lines=6, | |
| placeholder=f"Paste job description #{i+1} here...", | |
| label=f"Job #{i+1}", | |
| value=count[i] | |
| ) | |
| resumes_list.append(resume_input) | |
| submit_btn.click( | |
| fn=process_input, | |
| inputs=[job_description] + resumes_list, | |
| outputs=output | |
| ) | |
| add_resume_btn.click(add_resume_count, resumes_list, resume_count) | |
| # @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 Job Description") | |
| with gr.Column(): | |
| job_description = gr.Textbox( | |
| lines=8, | |
| placeholder="Paste Resume here...", | |
| label="Resume" | |
| ) | |
| output = gr.Textbox( | |
| lines=10, | |
| label="Job Suggestion Result", | |
| interactive=False | |
| ) | |
| submit_btn = gr.Button("π Job Suggestion") | |
| demo.launch() | |