File size: 4,093 Bytes
f6dc197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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"  # replace with your API endpoint
    headers = {
        "Content-Type": "application/json",
        "x-api-key": os.environ["API_KEY"],
    }  # adjust headers as needed
    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):
            # Insert a newline after each '.'
            # Insert a newline after each '.' and add "Candidate <follow up number>:\n" before each item
            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()