File size: 2,034 Bytes
7b8bd5a
 
ea77dc3
7b8bd5a
 
ea77dc3
7b8bd5a
ea77dc3
7b8bd5a
ea77dc3
7b8bd5a
 
 
 
 
 
ea77dc3
 
 
 
 
 
 
 
 
7b8bd5a
ea77dc3
 
 
 
 
 
7b8bd5a
 
ea77dc3
7b8bd5a
 
 
 
 
 
 
 
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
import os
import gradio as gr
import openai

# Retrieve the API key from the environment variable
api_key = os.getenv('OPENAI_API_KEY')
if api_key is None:
    raise Exception("Missing API key for OpenAI")

openai.api_key = api_key

def generate_description(title, location, desired_experience, preferred_experience, about_the_team):
    company_name = "Imaginary Inc."  # Placeholder company name
    company_description = "Imaginary Inc. is a forward-thinking company that values innovation, creativity, and diversity. We believe in fostering a positive work environment where every employee can thrive."  # Company branding message

    messages = [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": f"Company: {company_name}"},
        {"role": "user", "content": f"About the Company: {company_description}"},
        {"role": "user", "content": f"Job Title: {title}"},
        {"role": "user", "content": f"Job Location: {location}"},
        {"role": "user", "content": f"Desired Candidate Experience: {desired_experience}"},
        {"role": "user", "content": f"Preferred Candidate Experience: {preferred_experience}"},
        {"role": "user", "content": f"About the Team: {about_the_team}"},
        {"role": "user", "content": f"Generate a job description for the position {title} at {company_name}. The job is located in {location}. The desired experience for this role is {desired_experience} and the preferred experience is {preferred_experience}. The role is part of the following team: {about_the_team}. The description should align with the company's branding message: {company_description}"}
    ]

    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=messages,
        temperature=0.5,
        max_tokens=500
    )
    
    return response['choices'][0]['message']['content']

iface = gr.Interface(
    fn=generate_description,
    inputs=["text", "text", "text", "text", "text"],
    outputs="text"
)

iface.launch()