|
import json |
|
import os |
|
import gradio as gr |
|
import requests |
|
import recruiting_assistant |
|
|
|
|
|
def search_resume(input_text): |
|
url = f"https://n970resrb9.execute-api.eu-west-1.amazonaws.com/dev/prediction" |
|
headers = { |
|
"Content-Type": "application/json", |
|
"x-api-key": os.environ["API_KEY"], |
|
} |
|
response = requests.post( |
|
url, headers=headers, data=json.dumps({"text": input_text}) |
|
) |
|
response_data = response.json() |
|
|
|
if "prediction" in response_data: |
|
prediction = response_data["prediction"] |
|
if isinstance(prediction, list): |
|
|
|
|
|
updated_prediction = [ |
|
f"Candidate {i + 1}:\n=============================\n{s}" |
|
for i, s in enumerate(prediction) |
|
] |
|
updated_prediction = [s.replace(". ", ".\n") for s in updated_prediction] |
|
updated_prediction = [s.replace("â¢", "\n - ") for s in updated_prediction] |
|
return "\n\n".join(updated_prediction) |
|
return "No 'prediction' key found in the response or the 'body' is not a list." |
|
|
|
demo = gr.Blocks() |
|
|
|
with demo: |
|
with gr.Group(): |
|
with gr.Box(): |
|
with gr.Row(elem_id="prompt-container").style( |
|
mobile_collapse=False, equal_height=True |
|
): |
|
with gr.Column(): |
|
gr.Markdown( |
|
""" |
|
|
|
## 1. Provide a vacancy and get back relevant resumes from an entire database of resumes for various roles. |
|
""" |
|
) |
|
text_vacancy = gr.Textbox( |
|
hint="Paste here a Vacancy...", |
|
lines=7, |
|
label="Copy/paste here a vacancy", |
|
) |
|
b1 = gr.Button("Search Resume").style( |
|
margin=False, |
|
rounded=(False, True, True, False), |
|
full_width=False, |
|
) |
|
text_search_result = gr.Textbox( |
|
hint="Top resumes will appear here ...", |
|
label="Top resumes found in the database", |
|
) |
|
b1.click( |
|
search_resume, inputs=text_vacancy, outputs=text_search_result |
|
) |
|
gr.Markdown( |
|
""" |
|
|
|
## 2. Select an appropriate resume for this vacancy, paste it in the textfield and get a relevant introduction email. |
|
""" |
|
) |
|
text_resume = gr.Textbox( |
|
hint="Paste here a Resume...", |
|
label="Copy / Paste here your prefered resume from above and click the button to write an intro ", |
|
) |
|
b2 = gr.Button("Write a relevant intro").style( |
|
margin=False, |
|
rounded=(False, True, True, False), |
|
full_width=False, |
|
) |
|
gr.Markdown( |
|
""" |
|
|
|
## 3. You have a relevant introduction email to send to the customer. |
|
""" |
|
) |
|
text_intro = gr.Textbox(label="Intro Email") |
|
evaluation = gr.Textbox(label="Evaluation of the skills") |
|
b2.click( |
|
recruiting_assistant.create_intro, |
|
inputs=[text_vacancy, text_resume], |
|
outputs=[text_intro, evaluation], |
|
) |
|
|
|
gr.Examples( |
|
fn=search_resume, |
|
inputs=text_vacancy, |
|
outputs=text_search_result, |
|
cache_examples=False, |
|
) |
|
|
|
demo.launch() |
|
|