| import pandas as pd |
|
|
| import concurrent.futures |
| import time |
|
|
| import os |
| import tqdm |
|
|
| from dotenv import load_dotenv |
|
|
| import re |
|
|
| import openai |
|
|
| load_dotenv() |
|
|
| openai.api_type = os.getenv("AZURE_API_TYPE") |
| openai.api_base = os.getenv("AZURE_API_BASE") |
| openai.api_version = os.getenv("AZURE_API_VERSION") |
| openai.api_key = os.getenv("AZURE_API_KEY") |
|
|
| def get_completion(prompt, bot_role="You are an AI assistant that helps recruiters write job descriptions.", model="gpt-3.5-turbo"): |
| messages = [{"role": "user", "content": prompt}] |
| response = openai.ChatCompletion.create(engine="gpt-35-turbo", |
| messages=[{ |
| "role": "system", |
| "content": bot_role |
| }, { |
| "role": "user", |
| "content": prompt |
| }], |
| temperature=0.7, |
| max_tokens=800, |
| top_p=0.95, |
| frequency_penalty=0, |
| presence_penalty=0, |
| stop=None) |
| return response.choices[0].message["content"] |
|
|
| prompt_cols_jd = [ |
| 'industry', 'location', 'job_function', 'education_name', |
| 'education_area', 'years_of_experience', 'employment_type', |
| 'start_date', 'number_of_weeks', 'skills' |
| ] |
| prompt_cols_req = ['industry', 'job_function', 'years_of_experience', 'skills'] |
|
|
| start_prompt_jd_orig = "Generate a job description for this role. Include the job description, responsibilities, and skills. Do not include a requirements section. " |
| start_prompt_req_orig = "Create a list of requirements for this role. Please list each requirement one by one. The section starts with Requirements: " |
|
|
| def generate_prompt(jd_dict, req_dict): |
| start_prompt_jd_orig = "Generate a job description for this role. Include the job description, responsibilities, and skills. Do not include a requirements section. " |
| start_prompt_req_orig = "Create a list of requirements for this role. Please list each requirement one by one. The section starts with Requirements: " |
| start_prompt_jd = start_prompt_jd_orig |
| start_prompt_req = start_prompt_req_orig |
| for key, value in jd_dict.items(): |
| if value: |
| start_prompt_jd += "\n" + key +": " + str(value) |
| |
| for key, value in req_dict.items(): |
| if value: |
| start_prompt_req += "\n" + key +": " + str(value) |
| return start_prompt_jd, start_prompt_req |
|
|
| import gradio as gr |
|
|
| def generate_text(industry, location, job_function, years_of_experience, employment_type, start_date, |
| number_of_weeks, skills): |
| jd_dict = {'industry':industry, 'location':location, |
| 'job_function':job_function, 'years_of_experience': years_of_experience, |
| 'employment_type':employment_type, 'start_date':start_date, |
| 'number_of_weeks':number_of_weeks,'skills':skills} |
| req_dict = {'industry':industry, 'job_function':job_function, 'years_of_experience': years_of_experience, |
| 'skills': skills} |
| |
| start_prompt_jd, start_prompt_req = generate_prompt(jd_dict, req_dict) |
| jd_result = get_completion(start_prompt_jd) |
| req_result = get_completion(start_prompt_req) |
|
|
| return jd_result, req_result |
|
|
| demo = gr.Interface(fn=generate_text, inputs=["text","text","text","text","text","text","text","text"], outputs=["text", "text"]) |
| demo.launch( share = True) |
|
|
|
|
|
|