Spaces:
Running
Running
Added re, added logic for checking score, Improved Intro prompt
Browse files- app.py +91 -70
- requirements.txt +2 -1
app.py
CHANGED
@@ -2,6 +2,7 @@ from openai import OpenAI
|
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
import os
|
|
|
5 |
|
6 |
client = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))
|
7 |
|
@@ -28,7 +29,7 @@ step1Statement = (
|
|
28 |
|
29 |
| Input | Good Inputs | Bad Inputs |
|
30 |
|---------------|---------------|---------------|
|
31 |
-
| Audience
|
32 |
| Problem | HR Recruiters have the problem of crafting job ads that are clear, engaging, and appealing to the ideal candidates. Many job ads fail to capture the essence of the role or the company culture, resulting in a mismatch of applications and missed opportunities to attract top talent. | Creating job ads takes time |
|
33 |
| Solution | ChatGPT can assist in generating clear, and inclusive job descriptions by providing suggestions on language, structure, and content. It can help ensure the job ad is free from biased language, aligns with the company's values, and speaks directly to the desired audience. | ChatGPT can help in creating job ads |
|
34 |
| Video Objective | The objective of the video is to teach HR Recruiters how to use ChatGPT to: 1) create a draft of a job ad that is clear, free from biased language, aligns with company values, and speaks directly to the target audience. | Teach people how to make job ads |
|
@@ -41,7 +42,7 @@ step2Statement = (
|
|
41 |
"""
|
42 |
## Step 2. Review each output
|
43 |
In this section, review the result in each substep in order. If you are not happy with the results, press the **Regenerate Current Step** button
|
44 |
-
until you are happy. Then, you can press the **Generate Next Step
|
45 |
"""
|
46 |
)
|
47 |
|
@@ -53,7 +54,6 @@ step3Statement = (
|
|
53 |
"""
|
54 |
)
|
55 |
|
56 |
-
|
57 |
# Final Global Vars
|
58 |
Hook = ""
|
59 |
TitleAndIntro = ""
|
@@ -80,56 +80,75 @@ def GenerateHook(audienceInput, problemInput, solutionInput, objectiveInput, rev
|
|
80 |
|
81 |
empty_inputs = [name for name, value in inputs.items() if not value]
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
if empty_inputs:
|
84 |
return ( """Please make sure to fill in these empty inputs: \n""" + "\n".join(empty_inputs))
|
|
|
85 |
else:
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
},
|
107 |
-
{
|
108 |
-
"role": "assistant",
|
109 |
-
"content": "Hello, social media marketers! Ever whipped up a killer piece of content only to realize it just seems... off-brand? What if you could run a quality check to ensure your message is always in line with your company's brand voice? Let me introduce you to your new best friend, ChatGPT! This savvy tool can check your content before you post and offer suggestions to better align with your brand. Keep watching, and we'll show you how."
|
110 |
-
},
|
111 |
-
{
|
112 |
-
"role": "user",
|
113 |
-
"content": "Target Audience: members of the sales team.\nProblem: Members of the sales team often spend a lot of time creating personalized emails for customers in different sales scenarios. \nSolution: With ChatGPT, they can use a prompt and create email templates for different sales scenarios. \nVideo Objective: The objective of the video is to teach the viewer how to use ChatGPT to create email templates for customers and various sales scenarios, so they no longer need to write emails from scratch every single time. "
|
114 |
-
},
|
115 |
-
{
|
116 |
-
"role": "assistant",
|
117 |
-
"content": "Hey sales pros! Isn't it exhausting to constantly craft unique emails for every different sales scenario? Imagine having a magic tool that helps you create personalized email templates in a snap! Sounds good, right? That tool is called ChatGPT. With it, you can easily create tailor-made email templates for your customers in no time, guaranteeing you never have to start from scratch again. Stick with us in this video, and we'll show you how to turn those long hours into mere minutes."
|
118 |
-
},
|
119 |
-
{
|
120 |
"role": "user",
|
121 |
-
"content":
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
|
135 |
#Generate Title and Intro Function
|
@@ -165,26 +184,26 @@ def GenerateTitleAndIntro(audienceInput, problemInput, solutionInput, objectiveI
|
|
165 |
response = client.chat.completions.create(
|
166 |
model="gpt-4",
|
167 |
messages=[
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
{
|
189 |
"role": "user",
|
190 |
"content": user_message_content
|
@@ -474,7 +493,8 @@ def ReviewAnswers(audienceInput, problemInput, solutionInput, objectiveInput):
|
|
474 |
|
475 |
review = response.choices[0].message.content
|
476 |
return review
|
477 |
-
|
|
|
478 |
with gr.Blocks(theme=gr.themes.Soft()) as main:
|
479 |
with gr.Column():
|
480 |
gr.Markdown(introStatement)
|
@@ -578,4 +598,5 @@ with gr.Blocks(theme=gr.themes.Soft()) as main:
|
|
578 |
|
579 |
|
580 |
# Launch
|
581 |
-
main.launch()
|
|
|
|
2 |
import random
|
3 |
import gradio as gr
|
4 |
import os
|
5 |
+
import re
|
6 |
|
7 |
client = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))
|
8 |
|
|
|
29 |
|
30 |
| Input | Good Inputs | Bad Inputs |
|
31 |
|---------------|---------------|---------------|
|
32 |
+
| Audience | HR recruiters | Employees |
|
33 |
| Problem | HR Recruiters have the problem of crafting job ads that are clear, engaging, and appealing to the ideal candidates. Many job ads fail to capture the essence of the role or the company culture, resulting in a mismatch of applications and missed opportunities to attract top talent. | Creating job ads takes time |
|
34 |
| Solution | ChatGPT can assist in generating clear, and inclusive job descriptions by providing suggestions on language, structure, and content. It can help ensure the job ad is free from biased language, aligns with the company's values, and speaks directly to the desired audience. | ChatGPT can help in creating job ads |
|
35 |
| Video Objective | The objective of the video is to teach HR Recruiters how to use ChatGPT to: 1) create a draft of a job ad that is clear, free from biased language, aligns with company values, and speaks directly to the target audience. | Teach people how to make job ads |
|
|
|
42 |
"""
|
43 |
## Step 2. Review each output
|
44 |
In this section, review the result in each substep in order. If you are not happy with the results, press the **Regenerate Current Step** button
|
45 |
+
until you are happy. Then, you can press the **Generate Next Step** button. This button will generate the next section.
|
46 |
"""
|
47 |
)
|
48 |
|
|
|
54 |
"""
|
55 |
)
|
56 |
|
|
|
57 |
# Final Global Vars
|
58 |
Hook = ""
|
59 |
TitleAndIntro = ""
|
|
|
80 |
|
81 |
empty_inputs = [name for name, value in inputs.items() if not value]
|
82 |
|
83 |
+
def check_reviews(reviewAnswersBox):
|
84 |
+
# Define the pattern to search for ratings
|
85 |
+
pattern = r'\b\d+/5\b'
|
86 |
+
|
87 |
+
# Find all instances of the pattern in the review text
|
88 |
+
ratings = re.findall(pattern, reviewAnswersBox)
|
89 |
+
|
90 |
+
# Check if all found ratings are 5/5 and ensure there are exactly 4 ratings
|
91 |
+
if len(ratings) == 4 and all(rating == '5/5' for rating in ratings):
|
92 |
+
return True
|
93 |
+
else:
|
94 |
+
return False
|
95 |
+
|
96 |
if empty_inputs:
|
97 |
return ( """Please make sure to fill in these empty inputs: \n""" + "\n".join(empty_inputs))
|
98 |
+
|
99 |
else:
|
100 |
|
101 |
+
if check_reviews(reviewAnswersBox):
|
102 |
+
|
103 |
+
global client
|
104 |
+
|
105 |
+
user_message_content = (
|
106 |
+
f"Target Audience: {audienceInput}\n"
|
107 |
+
f"Problem: {problemInput}\n"
|
108 |
+
f"Solution: {solutionInput}\n"
|
109 |
+
f"Video Objective: {objectiveInput}"
|
110 |
+
)
|
111 |
+
|
112 |
+
response = client.chat.completions.create(
|
113 |
+
model="gpt-4",
|
114 |
+
messages=[
|
115 |
+
{
|
116 |
+
"role": "system",
|
117 |
+
"content": "You are an expert script writer creating engaging YouTube tutorial scripts for beginners on how to use ChatGPT to solve the problems they encounter in the corporate environment. These scripts must be written in a simple conversational manner and targeted to a beginner of a specific target audience. Technical jargon and complex words must be avoided at all times. \n\nYour current task is to create a hook based on the script brief. The hook is designed to show the viewer what their problem is and how watching the video will help them with their problem. During the hook, we need to welcome the audience, present their SPECIFIC problem, and how SPECIFICALLY their problem can be solved with ChatGPT. Finally, we offer for them to keep watching so we can show them how."
|
118 |
+
},
|
119 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
"role": "user",
|
121 |
+
"content": "Target Audience: members of the social media marketing team.\nProblem: Members of the marketing team come up with a text content to post on social media, but it doesn't always match the company's brand voice. \nSolution: With ChatGPT, they can use a prompt to check if their content matches their brand voice and provide suggestions. \nVideo Objective: The objective of the video is to teach the viewer how to use ChatGPT to review social media text content to check if it matches the brand voice. "
|
122 |
+
},
|
123 |
+
{
|
124 |
+
"role": "assistant",
|
125 |
+
"content": "Hello, social media marketers! Ever whipped up a killer piece of content only to realize it just seems... off-brand? What if you could run a quality check to ensure your message is always in line with your company's brand voice? Let me introduce you to your new best friend, ChatGPT! This savvy tool can check your content before you post and offer suggestions to better align with your brand. Keep watching, and we'll show you how."
|
126 |
+
},
|
127 |
+
{
|
128 |
+
"role": "user",
|
129 |
+
"content": "Target Audience: members of the sales team.\nProblem: Members of the sales team often spend a lot of time creating personalized emails for customers in different sales scenarios. \nSolution: With ChatGPT, they can use a prompt and create email templates for different sales scenarios. \nVideo Objective: The objective of the video is to teach the viewer how to use ChatGPT to create email templates for customers and various sales scenarios, so they no longer need to write emails from scratch every single time. "
|
130 |
+
},
|
131 |
+
{
|
132 |
+
"role": "assistant",
|
133 |
+
"content": "Hey sales pros! Isn't it exhausting to constantly craft unique emails for every different sales scenario? Imagine having a magic tool that helps you create personalized email templates in a snap! Sounds good, right? That tool is called ChatGPT. With it, you can easily create tailor-made email templates for your customers in no time, guaranteeing you never have to start from scratch again. Stick with us in this video, and we'll show you how to turn those long hours into mere minutes."
|
134 |
+
},
|
135 |
+
{
|
136 |
+
"role": "user",
|
137 |
+
"content": user_message_content
|
138 |
+
}
|
139 |
+
],
|
140 |
+
temperature=1,
|
141 |
+
max_tokens=256,
|
142 |
+
top_p=1,
|
143 |
+
frequency_penalty=0,
|
144 |
+
presence_penalty=0
|
145 |
+
)
|
146 |
+
|
147 |
+
Hook = response.choices[0].message.content
|
148 |
+
return Hook
|
149 |
+
|
150 |
+
else:
|
151 |
+
return "Not all questions received a 5/5 rating and this may affect the quality of the script π. Please try again."
|
152 |
|
153 |
|
154 |
#Generate Title and Intro Function
|
|
|
184 |
response = client.chat.completions.create(
|
185 |
model="gpt-4",
|
186 |
messages=[
|
187 |
+
{
|
188 |
+
"role": "system",
|
189 |
+
"content": "You are an expert script writer creating engaging YouTube tutorial scripts for beginners on how to use ChatGPT to solve the problems they encounter in the corporate environment. These scripts must be written in a simple conversational manner. Technical jargon and complex words must be avoided at all times. Do not use words like \"intricacy,\" \"robust,\" \"daunting,\" \"crucial,\" or \"compelling\" and other similar words. \n\nYour current task is to create a title and introduction based on the script brief that consist of a target audience, problem, solution, and video objective. \n\nThe title should be visualizing in an engaging way the video's objective. The title must be straight to the point, consist of a maximum of two phrases. It must not use abstract phrasing. \n\nThe intro should start by describing and explaining the key topic of the tutorial. For example, if the tutorial is about Brand Voice on social media, then it must start by explaining what brand voice is and why it's important. Make sure not to greet the specific target audience as this has already been done in a previous section. Technical jargon and complex words must be avoided at all times. Do not use words like \"intricacy,\" \"robust,\" \"daunting,\" \"crucial,\" or \"compelling\" and other similar words. \n\nAfter this description, it then must proceed with explaining what task is to be performed related to the key topic and why it's important to perform that task in a certain way. \n\nAnd finally, the intro wraps up with how the task can be performed with the help of ChatGPT. However, make sure not to say anything like \"In this tutorial, you will learn how to...\" because this is going to be covered in the next section. "
|
190 |
+
},
|
191 |
+
{
|
192 |
+
"role": "user",
|
193 |
+
"content": "Target Audience: members of the social media marketing team.\nProblem: Members of the marketing team come up with a text content to post on social media, but it doesn't always match the company's brand voice. \nSolution: With ChatGPT, they can use a prompt to check if their content matches their brand voice and provide suggestions. \nVideo Objective: The objective of the video is to teach the viewer how to use ChatGPT to review social media text content to check if it matches the brand voice. "
|
194 |
+
},
|
195 |
+
{
|
196 |
+
"role": "assistant",
|
197 |
+
"content": "Title: Ensuring Consistent Brand Voice on Social Media with ChatGPT\n\nWelcome to our guide on keeping your brand's voice consistent across social media, with a little help from ChatGPT.\n\nLet's start with the basics: your brand voice. Think of it as the personality of your company in words. It's how you talk to your audience, making your brand feel familiar and unique. Whether it's fun, serious, or something in between, your brand voice helps you connect with people in a meaningful way.\n\nBut here's the challenge: making sure this voice stays the same across all your social media posts can be tough. Ever been about to post something and stopped to wonder, \"Does this really sound like us?\" This is a common issue in social media marketing, where being consistent is important but not always easy.\n\nThat's where ChatGPT comes in. It's like your behind-the-scenes helper that can make sure every tweet, post, or update sounds exactly like your brand. With ChatGPT, you can make sure your brand's personality is always the star of the show on social media. Let's dive in."
|
198 |
+
},
|
199 |
+
{
|
200 |
+
"role": "user",
|
201 |
+
"content": "Target Audience: members of the sales team.\nProblem: Members of the sales team often spend a lot of time creating personalized emails for customers in different sales scenarios. \nSolution: With ChatGPT, they can use a prompt and create email templates for different sales scenarios. \nVideo Objective: The objective of the video is to teach the viewer how to use ChatGPT to create email templates for customers and various sales scenarios, so they no longer need to write emails from scratch every single time. "
|
202 |
+
},
|
203 |
+
{
|
204 |
+
"role": "assistant",
|
205 |
+
"content": "Title: Create Sales Email Templates with ChatGPT\n\nWelcome to this tutorial, where we address a common challenge faced by sales professionals: the time-consuming task of writing personalized emails for different sales scenarios. Personalizing emails is crucial because it helps build stronger connections with your customers. It shows that you see them as individuals with unique needs and preferences, which can significantly increase the effectiveness of your communication and boost your chances of making a sale.\n\nHowever, the catch is that crafting these personalized emails for various scenarios demands a considerable amount of time and effort. For example, you might need to create a warm introduction email for new leads, a detailed proposal email for interested prospects, a follow-up email after a meeting, or a thank-you email post-purchase. Each of these scenarios requires a different approach, tone, and content, making the task even more daunting.\n\nBut what if there was a way to streamline this process? That's where ChatGPT comes in. ChatGPT is an AI tool that can assist you in creating customized email templates for any sales situation. By leveraging intelligent prompts, ChatGPT helps generate relevant, personalized content, saving you time and effort. Stay with us as we dive into how ChatGPT can transform the way you handle sales emails, making your daily tasks smoother and more productive."
|
206 |
+
},
|
207 |
{
|
208 |
"role": "user",
|
209 |
"content": user_message_content
|
|
|
493 |
|
494 |
review = response.choices[0].message.content
|
495 |
return review
|
496 |
+
|
497 |
+
# Main
|
498 |
with gr.Blocks(theme=gr.themes.Soft()) as main:
|
499 |
with gr.Column():
|
500 |
gr.Markdown(introStatement)
|
|
|
598 |
|
599 |
|
600 |
# Launch
|
601 |
+
main.launch()
|
602 |
+
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
openai
|
2 |
-
gradio
|
|
|
|
1 |
openai
|
2 |
+
gradio
|
3 |
+
re
|