Team Ai
Apppublic

BtB-ExpC/Script_Generator_v2TURBO

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py336 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 two (Extra input and Team) are optional, but recommended. 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 specific tasks in a corporate environment. 13 14The structure of the script will look like this:15- Hook16- Title17- Introduction18- 2 Learning Objectives and their execution19- Conclusion20 21You'll only focus on the Hook, Title and Intro. Here are instructions for each:22 23The hook has only two goals, it must:241. Catch the audience's attention and convince them to watch more of the video.252. Serve as a setup for the video's content. 26 27The title:28Should roughly state what will be done in the video.29 30The intro:31Usually consists of three sentences. The first two sentences give an overview of the task being performed. The third sentence mentions how the tutorial will show the viewer how ChatGPT can expedite that task.32 33Sometimes additional instructions are given. These could be incorporated in the hook, title and/or intro if relevant, but often they should be ignored, if they apply to the learning objectives - which are outside the scope of your current task."""34UserPrompt_10 = r""""Topic of the tutorial: How to create a Job Ad with ChatGPT.35Additional instructions: Use digital marketing manager as an example role."""36AssistantPrompt_10 = r""""*HOOK*37If you want your job ads to be found by the right candidates, you have to incorporate the right SEO-friendly keywords.38 39But how do you accomplish this without a lot of experience in Search Engine Optimization? 40 41Well, with ChatGPT. 42 43*TITLE*44Create a Job Ad with ChatGPT45 46*INTRO*47In this digital age, getting your job ad to stand out amongst the rest is crucial to finding the best candidates.48 49Today, 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."""50UserPrompt_11 = r""""Topic of the tutorial: How to plan and create follow-up sequences for a product launch with ChatGPT.51"""52AssistantPrompt_11 = r""""*HOOK*53Imagine crafting the PERFECT follow-up sequences, effortlessly, each time you're gearing up for a product launch.  54 55Sounds like a dream, right?56 57But with ChatGPT, it's reality.   58 59*TITLE*60Craft Product Launch Follow-up Sequences with ChatGPT61 62*INTRO*63Follow-up sequences. They're like friendly nudges after a first hello, making sure you don't fade away from your clients' memory.64 65In this tutorial, we'll walk through how to harness ChatGPT to create efficient and effective follow-ups."""66 67# Define messages for stepTwo68SystemPrompt_20 = r"""You are a script writer and prompt engineer creating engaging YouTube tutorial scripts on how to use ChatGPT for specific tasks in a corporate environment. 69 70Given some instructions, a hook, a title, and an introduction, you design the execution part of the script. Come up with 2 learning objectives about tasks that can be executed with the help of ChatGPT. This is the structure you'll follow:71 72- Learning Objectives Summary73- Learning Objective 174- Learning Objective 275- Learning Objective 3 (this third one is optional)76- Conclusion77 78The learning objectives state the specific learning objectives that will be covered in the tutorial. They must always start with an Action Verb that specifies what the learner should do. Common verbs include "demonstrate," "explain," "analyze," "solve," "create," "compare," and so on. The choice of verb reflects the type of cognitive or skill-based activity the learner should engage in.79 80Make sure to also include:81- the exact prompt(s) the user needs to type into ChatGPT;82- realistic sample data for a case study, if applicable."""83UserPrompt_20 = r"""Topic of the tutorial: How to create a Job Ad with ChatGPT.84Additional instructions: Use digital marketing manager as an example role.85 86*HOOK*87If you want your job ads to be found by the right candidates, you have to incorporate the right SEO-friendly keywords.88 89But how do you accomplish this without a lot of experience in Search Engine Optimization? 90 91Well, with ChatGPT. 92 93*TITLE*94Create a Job Ad with ChatGPT95 96*INTRO*97In this digital age, getting your job ad to stand out amongst the rest is crucial to finding the best candidates.98 99Today, 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."""100AssistantPrompt_20 = r"""*LEARNING OBJECTIVES SUMMARY*101You will learn how to:102-	Create an ideal job description103-	Extract SEO-friendly keywords 104-	Craft a job ad 105 106Let's dive right in!107 108*LEARNING OBJECTIVE 1*109You can't create the perfect job ad without first creating the job description. 110 111Creating 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.   112 113To create a basic job description, you at least need to define the job title, the overview of the role, and the role's key responsibilities.114 115 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.    116 117Let's say you've been tasked to recruit a 'Digital Marketing Manager'.118 119Gather as much information as you can on the specifics of this job from the person that made the request. 120 121For this tutorial, we’ll be using the following sample information. 122 123The job title is "Digital marketing manager."124 125Here's an overview of the role: "The digital marketing manager is responsible for managing the overall digital marketing strategy of xpedite.ai. He/she is also responsible for:126-	overseeing online marketing campaigns and other digital projects to optimize online brand presence and boost revenue.127-	managing a team of 3 digital marketers." 128 129The 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."130 131Now, we're ready to write our prompt. 132 133Type: 134“You are a recruiter. Create a job description for a digital marketing manager.135 136Here are some additional details to consider when writing the job description:”137 138Then, paste the details you gathered previously.139 140Then press the send button.141 142 143ChatGPT wrote some basic details, the overview of the role, and key responsibilities of the role. 144 145It also included [basic and preferred qualifications], [what's in it for the applicant], and [more instructions].146 147Make sure to review and revise this job description so it effectively communicates your expectations. 148 149*LEARNING OBJECTIVE 2*150With this description, we can proceed to extract keywords which potential candidates might use when searching for this job.151 152Keywords are important because they make your job ad discoverable. The best keywords should resonate with the job seekers' search behavior.153 154Let's get keywords from ChatGPT. 155 156Type:157"Provide keywords related to the role of Digital Marketing Manager based on the description you've provided me."158 159Then, press the send message button. 160 161ChatGPT came up with a couple of keywords that we can use when posting our final job ad. 162 163We can also incorporate these keywords into the job ad itself.164 165*LEARNING OBJECTIVE 3*166With our description and keywords in hand, let's craft a job ad that integrates them both seamlessly.  167 168Type:169"Using the job description and the keywords you've provided, draft a job ad for a Digital Marketing Manager."170 171 Then, press the send button.   172 173Here's the response. 174 175 176ChatGPT 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. 177 178Make sure to review and revise the ad and verify that all information is accurate before posting it online. 179 180*CONCLUSION*181That's it!182 183By leveraging the power of ChatGPT-4, HR professionals can create job advertisements that stand out and attract top talent.184 185Remember, in the digital age of recruitment, your job ad is your first impression. So make it count!"""186 187 188# Function to make API call189def api_call(messages, temperature=0.9, model="gpt-4-1106-preview"):190    return openai.ChatCompletion.create(191        messages=messages,192        temperature=temperature,193        model=model194    ).choices[0].message.content195 196 197# Function to be called by Gradio interface198def process_inputs(EPA_title, Extra_input, Department):199    # Check if EPA_title is empty200    if not EPA_title:201        return manual202    if not Extra_input and not Department:203        stepOne = [204            {"role": "system", "content": SystemPrompt_10},205            {"role": "user", "content": UserPrompt_10},206            {"role": "assistant", "content": AssistantPrompt_10},207            {"role": "user", "content": UserPrompt_11},208            {"role": "assistant", "content": AssistantPrompt_11},209            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}"""}210        ]211        Script_1st_half = api_call(stepOne, 0.7)212 213        stepTwo = [214            {"role": "system", "content": SystemPrompt_20},215            {"role": "user", "content": UserPrompt_20},216            {"role": "assistant", "content": AssistantPrompt_20},217            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}218            219                    {Script_1st_half}"""}220        ]221        Script_2nd_half = api_call(stepTwo, 0.7)222        Script_complete = Script_1st_half + "\n\n" + Script_2nd_half223        return Script_complete224    if Extra_input and not Department:225        stepOne = [226            {"role": "system", "content": SystemPrompt_10},227            {"role": "user", "content": UserPrompt_10},228            {"role": "assistant", "content": AssistantPrompt_10},229            {"role": "user", "content": UserPrompt_11},230            {"role": "assistant", "content": AssistantPrompt_11},231            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title} 232                    Additional instructions: {Extra_input}"""}233        ]234        Script_1st_half = api_call(stepOne, 0.7)235 236        stepTwo = [237            {"role": "system", "content": SystemPrompt_20},238            {"role": "user", "content": UserPrompt_20},239            {"role": "assistant", "content": AssistantPrompt_20},240            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}241                    Additional instructions: {Extra_input}242                    243                    {Script_1st_half}"""}244        ]245        Script_2nd_half = api_call(stepTwo, 0.7)246        Script_complete = Script_1st_half + "\n\n" + Script_2nd_half247        return Script_complete248 249    if Department and not Extra_input:250        stepOne = [251            {"role": "system", "content": SystemPrompt_10},252            {"role": "user", "content": UserPrompt_10},253            {"role": "assistant", "content": AssistantPrompt_10},254            {"role": "user", "content": UserPrompt_11},255            {"role": "assistant", "content": AssistantPrompt_11},256            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}257                    The tutorial is aimed at employees in a {Department} department."""}258        ]259        Script_1st_half = api_call(stepOne, 0.7)260 261        stepTwo = [262            {"role": "system", "content": SystemPrompt_20},263            {"role": "user", "content": UserPrompt_20},264            {"role": "assistant", "content": AssistantPrompt_20},265            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}266                    The tutorial is aimed at employees in a {Department} department.267 268                    {Script_1st_half}"""}269        ]270        Script_2nd_half = api_call(stepTwo, 0.7)271        Script_complete = Script_1st_half + "\n\n" + Script_2nd_half272        return Script_complete273 274    else: # All fields filled out275        # Step 1: User input and first API call ~5secs276        stepOne = [277            {"role": "system", "content": SystemPrompt_10},278            {"role": "user", "content": UserPrompt_10},279            {"role": "assistant", "content": AssistantPrompt_10},280            {"role": "user", "content": UserPrompt_11},281            {"role": "assistant", "content": AssistantPrompt_11},282            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}. 283                    Additional instructions: {Extra_input}.284                    The tutorial is aimed at employees in a {Department} department."""}285        ]286        Script_1st_half = api_call(stepOne, 0.7)287 288        stepTwo = [289            {"role": "system", "content": SystemPrompt_20},290            {"role": "user", "content": UserPrompt_20},291            {"role": "assistant", "content": AssistantPrompt_20},292            {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}293            Additional instructions: {Extra_input}294            The tutorial is aimed at employees in a {Department} department.295 296            {Script_1st_half}"""}297        ]298        Script_2nd_half = api_call(stepTwo, 0.7)299        Script_complete = Script_1st_half + "\n\n" + Script_2nd_half300        return Script_complete301 302 303departments = {304    "3D": "3D Modeling",  # Label and value differ305    "Client Support": "Client Support",306    "Data Entry & Back Office": "Data Entry & Back Office",307    "Education Administration (ENI)": "Education Administration",  # Label and value differ308    "Finance": "Finance",309    "Marketing": "Marketing",310    "HR": "HR",311    "IT": "IT",312    "Legal": "Legal",313    "Product Management": "Product Management",314    "Project Management/Coordination": "Project Management/Coordination",315    "Process Management": "Process Management",316    "QA": "QA",317    "R&D": "R&D",318    "Sales": "Sales",319    "Software": "Software",320    "Video Production": "Video Production",321    "Visual Management": "Visual Management"322}323 324# Create the Gradio interface325iface = gr.Interface(326    fn=process_inputs,327    inputs=[328        gr.Textbox(lines=2, label='EPA description here... (use the phrasing: "How to do X using ChatGPT")'),329        gr.Textbox(lines=2, label='Extra input here... (optional, put any extra requirements or relevant context)'),330        gr.Dropdown(choices=departments, label="Select team", searchable=True)331    ],332    outputs=gr.Textbox(label="Script", show_copy_button=True)333)334 335iface.launch(share=True)336iface.launch()