robertselvam's picture
Update app.py
2454ce8
raw
history blame
2.69 kB
import openai
import gradio as gr
import os
class JobDescription():
def __init__(self):
# Set up your OpenAI API credentials
openai.api_key = os.getenv("OPENAI_API_KEY")
def generate_job_description(self, role, experience):
# Generate a response from the GPT-3 model
prompt = f"""Your task is generate Job description for this {role} with {experience} years of experience.
Job Description Must have
1. Job Title
2. Job Summary : [200 words]
3. Responsibilities : Five Responsibilities in five lines
4. Required Skills : Six Skills
5. Qualifications
These topics must have in that Generated Job Description.
"""
response = openai.Completion.create(
engine='text-davinci-003', # Choose the GPT-3 engine you want to use
prompt=prompt,
max_tokens=500, # Set the maximum number of tokens in the generated response
temperature=0.5, # Controls the randomness of the output. Higher values = more random, lower values = more focused
)
# Extract the generated text from the API response
generated_text = response.choices[0].text.strip()
return generated_text
def gradio_interface(self):
with gr.Blocks(css="style.css",theme='karthikeyan-adople/hudsonhayes-gray') as app:
gr.HTML("""<center class="darkblue" style='background-color:rgb(0,1,36); text-align:center;padding:30px;'><center>
<img class="leftimage" align="left" src="https://companieslogo.com/img/orig/RAND.AS_BIG-0f1935a4.png?t=1651813778" alt="Image" width="210" height="210">
<h1 class ="center" style="color:#fff">ADOPLE AI</h1></center>
<br><center><h1 style="color:#fff">Generate Job Description</h1></center>""")
with gr.Row(elem_id="col-container"):
with gr.Column():
gr.HTML("<br>")
gr.HTML(
"""<h1 style="text-align:center; color:"white">Generate Job Description</h1> """
)
with gr.Column():
rolls = gr.Textbox(label="Role")
with gr.Column():
experience = gr.Textbox(label="Experience")
with gr.Column():
analyse = gr.Button("Generate JD")
with gr.Column():
result = gr.Textbox(label="Job Description",lines=8)
analyse.click(self.generate_job_description, [rolls,experience], result)
app.launch()
jd=JobDescription()
jd.gradio_interface()