Team Ai
Apppublic

BtB-ExpC/Script_Generator

sourceHugging Faceupdated 3y agoView on Hugging Face
1likes
app.py183 linesDownload Raw Back to root
1import openai2import random3import gradio as gr4import os5 6openai.api_key = os.environ["OpenAPI_Key"]7 8manual = r"""Input your variables in the fields on the left. The last one (Extra input...) is optional, you can use it to steer the prompt into a certain direction by adding more requirements.9"""10 11# Define the messages for step_112SystemPrompt_10 = r""""You are a script writer and prompt engineer creating engaging YouTube tutorial scripts on how to use ChatGPT for various tasks in a corporate environment. 13 14Make sure to include what sort of information the user needs to type into the prompt. 15 16When creating the script, please follow this structure: 17- Hook18- Title19- Introduction20- Learning Objectives Summary21- Learning Objective 122- Learning Objective 223- Conclusion24 25Feel free to be creative."""26UserPrompt_10 = r""""Create a script for teaching an employee: How to create a Job Ad with ChatGPT.27Additional instructions: Use digital marketing manager as an example role."""28AssistantPrompt_10 = r""""*HOOK*29If you want your job ads to be found by the right candidates, you have to incorporate the right SEO-friendly keywords.30 31But how do you accomplish this without a lot of experience in Search Engine Optimization? 32 33Well, with ChatGPT. 34 35*TITLE*36Create a Job Ad with ChatGPT37 38*INTRO*39In this digital age, getting your job ad to stand out amongst the rest is crucial to finding the best candidates.40 41Today, we'll show you how to use ChatGPT to create a job ad that not only resonates with your ideal candidates, but also ranks high with SEO-friendly keywords. 42 43*LEARNING OBJECTIVES SUMMARY*44You will learn how to:45 46- Create an ideal job description47 48- Extract SEO Friendly Keywords 49 50- Craft a Job Ad 51 52Let's dive right in!53 54*LEARNING OBJECTIVE 1*55You can't create the perfect job ad without first creating the job description. 56 57Creating a comprehensive job description is critical for attracting the right candidates, setting expectations, and ensuring both the employee and employer understand the role's responsibilities.   58 59To create a basic job description, you would at least need to define the job title, the overview of the role, and the role's key responsibilities.60 61 It's also preferable to already identify any other details about the role, like qualifications and skills, experience level, salary and benefits, reporting structure, and working hours.    62 63Let's say you've been tasked to recruit a 'Digital Marketing Manager'.64 65Gather as much information as you can on the specifics of this job from the person that made the request. 66 67For this tutorial, we'll be using the following sample information.68 69 70The job title is "Digital marketing manager."71 72The overview of the role is "The digital marketing manager is responsible for managing the overall digital marketing strategy of xpedite.ai. He/she is also responsible for:73-	overseeing online marketing campaigns and other digital projects to optimize online brand presence and boost revenue.74-	manageing a team of 3 digital marketers." 75 76The key responsibilities of the role are "propose and execute digital marketing strategies, manage and oversee digital channels, monitor and measure ROI and KPIs of online campaigns."77 78Now, we're ready to write our prompt. 79 80Type: "You are a recruiter. Create a job description for a digital marketing manager.81 82 83Here are some additional details to consider when writing the job description:"84 85Then, paste the details you gathered previously.86 87Then press the send button.88 89ChatGPT wrote some basic details, the overview of the role, and key responsibilities of the role. 90 91It also included [basic and preferred qualifications], [what's in it for the applicant], and [more instructions].92 93 94Make sure to review and revise this job description so it effectively communicates your expectations. 95 96*LEARNING OBJECTIVE 2*97With this description, we can proceed to extract keywords which potential candidates might use when searching for this job.98 99Keywords are important because they make your job ad discoverable. The best keywords should resonate with the job seekers' search behavior.100 101Let's get keywords from ChatGPT. 102 103Type "Provide keywords related to the role of Digital Marketing Manager based on the description you've provided me."104 105Then, press the send message button. 106 107ChatGPT came up with a couple of keywords that we can use when posting our final job ad. 108 109We can also incorporate these keywords into the job ad itself.110 111With our description and keywords in hand, let's craft a job ad that integrates them both seamlessly.  112 113Type:114 115"Using the job description and the keywords you've provided, draft a job ad for a Digital Marketing Manager."116 117 Then, press the send button.   118 119Here's the response. 120 121 122ChatGPT drafted a job ad that contains specific details about the job description and incorporates keywords so that it's easier to find on the internet. 123 124Make sure to review and revise the ad and verify that all information is accurate before posting it online. 125 126*CONCLUSION*127That's it!128 129By leveraging the power of ChatGPT-4, HR professionals can create job advertisements that stand out and attract top talent.130 131Remember, in the digital age of recruitment, your job ad is your first impression. So make it count!"""132 133 134# Function to make API call135def api_call(messages, temperature=0.9, model="gpt-4-1106-preview"):136    return openai.ChatCompletion.create( 137        messages=messages,138        temperature=temperature,139        model=model140    ).choices[0].message.content141 142# Function to be called by Gradio interface143def process_inputs(EPA_title, Department, Extra_input):144    # Check if EPA_title and/or Department are empty145    if not EPA_title and not Department:146        return manual147    if not Extra_input:148        stepOne = [149            {"role": "system", "content": SystemPrompt_10},150            {"role": "user", "content": UserPrompt_10},151            {"role": "assistant", "content": AssistantPrompt_10},152            {"role": "user", "content": f"""Create a script for teaching an employee: {EPA_title}153The target audience is: a professional in a {Department} team."""}154        ]155    else:156        # Step 1: User input and first API call ~5secs157        stepOne = [158            {"role": "system", "content": SystemPrompt_10},159            {"role": "user", "content": UserPrompt_10},160            {"role": "assistant", "content": AssistantPrompt_10},161            {"role": "user", "content": f"""Create a script for teaching an employee: {EPA_title}162The target audience is: a professional in a {Department} team. 163Additional instructions: {Extra_input}"""}164        ]165    166    Script_1 = api_call(stepOne, 0.7)167    return Script_1168 169 170 171# Create the Gradio interface 172iface = gr.Interface(173    fn=process_inputs, 174    inputs=[175        gr.Textbox(lines=2, label='EPA title Here... (use the phrasing: "How to do X with ChatGPT")'), 176        gr.Textbox(lines=2, label='Department Here... (eg: Product Management)'), 177        gr.Textbox(lines=2, label='Extra input Here... (optional, put any extra requirements or relevant context)')178        ], 179    outputs=gr.Textbox(label="Script", show_copy_button=True)180)181 182iface.launch(share=True)183iface.launch()