File size: 2,000 Bytes
590f94a
8fc411c
590f94a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8fc411c
 
 
 
590f94a
 
8fc411c
 
 
590f94a
 
 
 
 
 
8fc411c
 
1e7b8f1
 
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
from transformers import pipeline, Conversation
import gradio as gr
from datetime import datetime

from transformers.utils import logging
logging.set_verbosity_error()

# Info about ['google/gemma-2b-it'](https://huggingface.co/google/gemma-2b-it)
chatbot = pipeline(task="conversational",
                   model="./models/google/gemma-2b-it")

def get_job_description(company_name, sector, job_position):
    start_time = datetime.now()

    messages = [
            {
                "role": "user",
                "content": f"""
                    You are the Talent Acquisition Manager at { company_name }, a company of the { sector } sector.
                    Your goal is to hire people in different departments of the company.
                    I want to generate a Job Description for the role '{ job_position }' in a creative, modern, formal and attractive way.
                    """
            },
            {
                "role": "assistant",
                "content": "Description:"
            }
        ]
    
    conversation = Conversation(messages)
    conversation = chatbot(conversation, do_sample=True, max_new_tokens=600, temperature=1)
    response = conversation.messages[-1]["content"]
    
    delta_time = datetime.now() - start_time

    return response, delta_time

with gr.Blocks() as demo:
    gr.Markdown(
    """
    # Job Description generator
    ### This SLM demo uses ['google/gemma-2b-it'](https://huggingface.co/google/gemma-2b-it)
    """)

    interface = gr.Interface(
        fn = get_job_description,
        inputs = [gr.Textbox(placeholder="Enter the company name", label="Company name"),
                  gr.Textbox(placeholder="Enter the company sector", label="Company sector"),
                  gr.Textbox(placeholder="Enter the job position", label="Job position")],
        outputs = [gr.Markdown(),
               gr.Textbox(label="Elapsed time")]
    )

demo.launch(server_port=7860)
# demo.launch(share=True, server_port=7860)