Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import google.generativeai as palm
|
| 4 |
+
|
| 5 |
+
# Retrieve the API key from the environment variable
|
| 6 |
+
api_key = os.getenv('GENERATIVE_AI_API_KEY')
|
| 7 |
+
if api_key is None:
|
| 8 |
+
raise Exception("Missing API key for Generative AI")
|
| 9 |
+
|
| 10 |
+
palm.configure(api_key=api_key)
|
| 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 |
+
f"Company: {company_name}",
|
| 28 |
+
f"About the Company: {company_description}",
|
| 29 |
+
f"Job Title: {title}",
|
| 30 |
+
f"Job Location: {location}",
|
| 31 |
+
f"Desired Candidate Experience: {desired_experience}",
|
| 32 |
+
f"Preferred Candidate Experience: {preferred_experience}",
|
| 33 |
+
f"About the Team: {about_the_team}",
|
| 34 |
+
"NEXT REQUEST",
|
| 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 = palm.chat(
|
| 39 |
+
**defaults,
|
| 40 |
+
context=context,
|
| 41 |
+
examples=examples,
|
| 42 |
+
messages=messages
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
return response.last
|
| 46 |
+
|
| 47 |
+
iface = gr.Interface(
|
| 48 |
+
fn=generate_description,
|
| 49 |
+
inputs=["text", "text", "text", "text", "text"],
|
| 50 |
+
outputs="text"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
iface.launch()
|