Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,48 +1,38 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
import
|
| 4 |
|
| 5 |
# Retrieve the API key from the environment variable
|
| 6 |
-
api_key = os.getenv('
|
| 7 |
if api_key is None:
|
| 8 |
-
raise Exception("Missing API key for
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
defaults = {
|
| 13 |
-
'model': 'models/chat-bison-001',
|
| 14 |
-
'temperature': 0.25,
|
| 15 |
-
'candidate_count': 1,
|
| 16 |
-
'top_k': 40,
|
| 17 |
-
'top_p': 0.95,
|
| 18 |
-
}
|
| 19 |
|
| 20 |
def generate_description(title, location, desired_experience, preferred_experience, about_the_team):
|
| 21 |
-
context = ""
|
| 22 |
-
examples = []
|
| 23 |
company_name = "Imaginary Inc." # Placeholder company name
|
| 24 |
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
|
| 25 |
|
| 26 |
messages = [
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
f"
|
| 30 |
-
f"Job
|
| 31 |
-
|
| 32 |
-
f"
|
| 33 |
-
f"
|
| 34 |
-
"
|
| 35 |
-
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}"
|
| 36 |
]
|
| 37 |
-
|
| 38 |
-
response =
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
)
|
| 44 |
|
| 45 |
-
return response
|
| 46 |
|
| 47 |
iface = gr.Interface(
|
| 48 |
fn=generate_description,
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
import openai
|
| 4 |
|
| 5 |
# Retrieve the API key from the environment variable
|
| 6 |
+
api_key = os.getenv('OPENAI_API_KEY')
|
| 7 |
if api_key is None:
|
| 8 |
+
raise Exception("Missing API key for OpenAI")
|
| 9 |
|
| 10 |
+
openai.api_key = api_key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def generate_description(title, location, desired_experience, preferred_experience, about_the_team):
|
|
|
|
|
|
|
| 13 |
company_name = "Imaginary Inc." # Placeholder company name
|
| 14 |
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
|
| 15 |
|
| 16 |
messages = [
|
| 17 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 18 |
+
{"role": "user", "content": f"Company: {company_name}"},
|
| 19 |
+
{"role": "user", "content": f"About the Company: {company_description}"},
|
| 20 |
+
{"role": "user", "content": f"Job Title: {title}"},
|
| 21 |
+
{"role": "user", "content": f"Job Location: {location}"},
|
| 22 |
+
{"role": "user", "content": f"Desired Candidate Experience: {desired_experience}"},
|
| 23 |
+
{"role": "user", "content": f"Preferred Candidate Experience: {preferred_experience}"},
|
| 24 |
+
{"role": "user", "content": f"About the Team: {about_the_team}"},
|
| 25 |
+
{"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}"}
|
| 26 |
]
|
| 27 |
+
|
| 28 |
+
response = openai.ChatCompletion.create(
|
| 29 |
+
model="gpt-3.5-turbo",
|
| 30 |
+
messages=messages,
|
| 31 |
+
temperature=0.5,
|
| 32 |
+
max_tokens=500
|
| 33 |
)
|
| 34 |
|
| 35 |
+
return response['choices'][0]['message']['content']
|
| 36 |
|
| 37 |
iface = gr.Interface(
|
| 38 |
fn=generate_description,
|