|
import openai |
|
import gradio as gr |
|
import os |
|
class JobDescription(): |
|
def __init__(self): |
|
|
|
openai.api_key = os.getenv("OPENAI_API_KEY") |
|
|
|
def generate_job_description(self, role, experience): |
|
|
|
|
|
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', |
|
prompt=prompt, |
|
max_tokens=500, |
|
temperature=0.5, |
|
) |
|
|
|
|
|
generated_text = response.choices[0].text.strip() |
|
|
|
return generated_text |
|
|
|
def gradio_interface(self): |
|
with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as app: |
|
gr.HTML("""<img class="leftimage" align="left" src="https://templates.images.credential.net/1612472097627370951721412474196.png" alt="Image" width="210" height="210"> |
|
<img class="rightimage" align="right" src="https://companieslogo.com/img/orig/RAND.AS_BIG-0f1935a4.png?t=1651813778" alt="Image" width="210" height="210">""") |
|
|
|
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() |