LinJulya commited on
Commit
1e49db4
·
1 Parent(s): a922de5

temp - replace code with scriptgenv3

Browse files
Files changed (1) hide show
  1. app.py +406 -78
app.py CHANGED
@@ -1,81 +1,409 @@
 
 
1
  import gradio as gr
2
  import os
3
- import openai
4
- import time
5
-
6
-
7
- def chatbot_response(prompt_topic):
8
- openai.api_key = os.environ.get('OPENAI_API_KEY')
9
-
10
- response = openai.ChatCompletion.create(
11
- model="gpt-4",
12
- messages=[
13
- {
14
- "role": "system",
15
- "content": "You are a prompt engineer. You are responsible for crafting high-quality prompts that drive precise and meaningful responses from language models like ChatGPT. You understand the nuances of language, context, and user needs and engineer prompts that help people solve problems. Your task is to generate useful and functional high-quality prompts for users.\n\nWhen responding, please follow this structure: \n- Prompt Template\n- Instructions\n- Example\n\nWhen asked for an automatic prompt, make sure to always include \"To better understand what I want and need, you should always answer by including a question that helps you better understand the context and my needs. Do you understand?\" in the prompt template."
16
- },
17
- {
18
- "role": "user",
19
- "content": "Create an automatic prompt for writing a meal plan with ChatGPT. "
20
- },
21
- {
22
- "role": "assistant",
23
- "content": "Prompt Template:\nYou are a professional in the field of nutrition and dietetics, who has helped numerous individuals to devise customized meal plans. Your task is now to create a comprehensive nutritional plan for a [DIETARY PREFERENCE] like me aiming to [HEALTH GOALS]. To better understand what I want and need, you should always answer by including a question that helps you better understand the context and my needs. Do you understand?\n\nInstructions:\n1. Mention Your Preferences and Goals: Specify your dietary preferences and health goals.\n2. Fill in the Template: Use the template to craft your automatic prompt.\n3. Input to ChatGPT: Once you've filled in the template, provide it to ChatGPT to receive a personalized nutritional plan based on your input.\n\nExample: \n\"You are a professional in the field of nutrition and dietetics, who has helped numerous individuals to devise customized meal plans. Your task is now to create a comprehensive nutritional plan for a vegetarian like me aiming to lose weight. To better understand what I want and need, you should always answer by including a question that helps you better understand the context and my needs. Do you understand?\""
24
- },
25
- {
26
- "role": "assistant",
27
- "content": "Write a non-automatic prompt on writing social media posts. The prompt should take other social media posts as input and use it as reference for tone and style. "
28
- },
29
- {
30
- "role": "user",
31
- "content": "Prompt Name: Social Media Post Generator\n\nDescription: This prompt is designed to help users craft engaging social media posts by referencing the tone and style of existing sample posts.\n\nPrompt Template: Given the following examples of social media posts, \"[SOCIAL MEDIA POST 1]\", \"[SOCIAL MEDIA POST 2]\" and \"[SOCIAL MEDIA POST 3]\", could you help me write a new post that maintains the same tone and style? My post should be about [TOPIC].\n\nInstructions:\n1. Identify Sample Posts: Choose three social media posts that reflect the tone and style you want your post to emulate.\n2. Determine the Topic: Decide what the topic of your new social media post will be.\n3. Fill in the Template: Replace the placeholders in the template with the information from steps 1-2:\n ◦ Replace [SOCIAL MEDIA POST 1], [SOCIAL MEDIA POST 2], and [SOCIAL MEDIA POST 3] with your chosen sample posts.\n ◦ Replace [TOPIC] with your decided topic.\n4. Input to ChatGPT: Once you've filled in the template, provide it to ChatGPT to generate a new social media post based on your input.\n\nExample: \"Given the following examples of social media posts, \"A day without coffee is like... just kidding, we have no idea!\", \"Coffee: because adulting is hard.\" and \"Life happens, coffee helps\", could you help me write a new post that maintains the same tone and style? My post should be about promoting our new coffee blend.\""
32
- },
33
- {
34
- "role": "user",
35
- "content": f"Create a prompt template for: {prompt_topic}"
36
- }
37
- ],
38
- temperature=0.7,
39
- max_tokens=4352,
40
- top_p=1,
41
- frequency_penalty=0,
42
- presence_penalty=0.6,
43
- stop=[" Human:", " AI:"]
44
- )
45
-
46
- return response.choices[0].message['content']
47
-
48
- def respond(input1, input2, input3, chatbot):
49
- if input2 == True:
50
- auto = "an automatic"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  else:
52
- auto = "a non-automatic"
53
-
54
- prompt_topic = "Write " + auto + " prompt on " + input1 + ". " + input3
55
- bot_response = chatbot_response(prompt_topic)
56
- chatbot.append((prompt_topic, bot_response))
57
- time.sleep(2)
58
- return chatbot
59
-
60
- with gr.Blocks() as demo:
61
- gr.Markdown(
62
- """
63
- # Prompt Generator Bot
64
- Input your parameters and press Generate.
65
- """)
66
- with gr.Row():
67
- with gr.Column(scale=1):
68
- prompt_title = gr.Textbox(placeholder="I need a prompt for ...", label="What is your prompt for?")
69
- type_auto = gr.Checkbox(label="An automatic prompt asks you what you need before giving you what you want. It usually starts with ChatGPT asking you questions. Do you want an automatic prompt?")
70
- extra = gr.Textbox(placeholder="Write your specifications in full sentences.", label="Do you have other specifications for your prompt?")
71
- btn = gr.Button("Generate")
72
-
73
- with gr.Column(scale=1):
74
- chatbot = gr.Chatbot(show_copy_button=True)
75
- with gr.Row():
76
- clear = gr.ClearButton([prompt_title, type_auto, extra, chatbot])
77
-
78
- #btn.click(fn=update, inputs=inp, outputs=None)
79
- btn.click(fn=respond, inputs=[prompt_title, type_auto, extra , chatbot], outputs=[chatbot])
80
-
81
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import random
3
  import gradio as gr
4
  import os
5
+
6
+ openai.api_key = os.environ.get('OPENAI_API_KEY')
7
+
8
+ manual = 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_1
12
+ SystemPrompt_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
+
14
+ Given 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:
15
+
16
+ - Learning Objectives Summary
17
+ - Learning Objective 1
18
+ - Learning Objective 2
19
+ - Learning Objective 3 (this third one is optional)
20
+ - Conclusion
21
+
22
+ The 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.
23
+
24
+ Make sure to also include:
25
+ - the exact prompt(s) the user needs to type into ChatGPT. These prompts need to be automatic prompts and follow best practices for prompt engineering like "define a role (you are an expert marketer, you are an expert recruiter) " and "provide necessary context." The first prompt always needs to be an automatic prompt, and end with "Ask me as many questions as you need until you have enough information to provide me with the desired output.";
26
+ - realistic sample data for a case study, if applicable;
27
+ - for every learning objective, explanations of concepts that the audience may not understand. """
28
+
29
+ UserPrompt_10 = r""""Task: Crafting product update checklists on product updates and new features for customer onboarding
30
+ Task Description: Review the latest product updates and new features, ensuring a comprehensive understanding of their functionalities and benefits.
31
+ Create detailed checklists that outline step-by-step procedures for clients to effectively integrate and utilize these updates and features in their existing systems or processes.
32
+ Ensure the checklists are clear, user-friendly, and tailored to support customers of varying technical proficiency, facilitating smooth onboarding and optimal use of the new product capabilities.
33
+ Additional instructions: The tutorial is aimed at employees in a Client Support department."
34
+
35
+ HOOK:
36
+ If you're in client support, you know how tricky it can be to explain new product features to a wide range of customers. Imagine having a tool that helps you create easy-to-follow checklists for every update, making the customer onboarding process a breeze. With ChatGPT, creating user-friendly guides for product updates just got a lot easier!
37
+
38
+ TITLE:
39
+ Create Easy-to-Follow Product Update Checklists with ChatGPT: A Guide for Client Support Teams
40
+
41
+ INTRO:
42
+ Hello there, Client Support team members! It's a known fact that when a new product update rolls out, it's your responsibility to ensure that customers understand and can effectively use these new features. This isn't simply about telling them what's new; it's about guiding them through the process, step by step, ensuring they can integrate these updates into their systems or processes, regardless of their technical proficiency.
43
+
44
+ But how do you create clear, user-friendly checklists that cater to customers with varying levels of expertise? That's where ChatGPT comes in. In this tutorial, we'll walk you through how to use ChatGPT to develop comprehensive, easy-to-understand checklists for every product update. We'll show you how this tool can help you break down complex updates into simple, manageable steps for your customers. Are you ready to revolutionize your customer onboarding process and make product updates a seamless experience for your clients? Let's get started!"""
45
+
46
+ AssistantPrompt_10 = r""""*LEARNING OBJECTIVES SUMMARY*
47
+ You will learn how to:
48
+ - Create an ideal job description
49
+ - Extract SEO-friendly keywords
50
+ - Craft a job ad
51
+
52
+ Let's dive right in!
53
+
54
+ *LEARNING OBJECTIVE 1*
55
+ First, let's create the ideal job description. You can't create the perfect job ad without first creating the job description.
56
+
57
+ A job description is a document that outlines the key responsibilities, qualifications, and skills required for a specific role, along with details about working conditions and reporting relationships.
58
+
59
+ Creating 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.
60
+
61
+ To 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.
62
+
63
+ 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.
64
+
65
+ Let's say you've been tasked to recruit a 'Digital Marketing Manager'.
66
+
67
+ Gather as much information as you can on the specifics of this job from the person that made the request.
68
+
69
+ For this tutorial, we’ll be using the following sample information.
70
+
71
+ The job title is "Digital marketing manager."
72
+
73
+ Here'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:
74
+ - overseeing online marketing campaigns and other digital projects to optimize online brand presence and boost revenue.
75
+ - managing a team of 3 digital marketers."
76
+
77
+ The 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."
78
+
79
+ Now, we're ready to write our prompt.
80
+
81
+ Type:
82
+ “You are an expert recruiter. Your current task is to create a job description for a digital marketing manager. Here are some additional details to consider when writing the job description: (Then, paste the details you gathered previously.)
83
+
84
+ Ask me as many questions as you need until you have enough information to provide me with the desired output."
85
+
86
+ Then press the send button.
87
+
88
+
89
+ ChatGPT asked relevant questions until it had enough information to come up with the desired output.
90
+
91
+ Make sure to review and revise this job description so it effectively communicates your expectations.
92
+
93
+ *LEARNING OBJECTIVE 2*
94
+ Now, we're ready to extract SEO-friendly keywords. With this description, we can proceed to extract keywords which potential candidates might use when searching for this job.
95
+
96
+ Keywords are important because they make your job ad discoverable. The best keywords should resonate with the job seekers' search behavior.
97
+
98
+ Let's get keywords from ChatGPT.
99
+
100
+ Type:
101
+ "Provide keywords related to the role of Digital Marketing Manager based on the description you've provided me."
102
+
103
+ Then, press the send message button.
104
+
105
+ ChatGPT came up with a couple of keywords that we can use when posting our final job ad.
106
+
107
+ We can also incorporate these keywords into the job ad itself.
108
+
109
+ *LEARNING OBJECTIVE 3*
110
+ Finally, let's craft a job ad. With our description and keywords in hand, let's craft a job ad that integrates them both seamlessly.
111
+
112
+ Type:
113
+ "Using the job description and the keywords you've provided, draft a job ad for a Digital Marketing Manager."
114
+
115
+ Then, press the send button.
116
+
117
+ Here's the response.
118
+
119
+
120
+ ChatGPT 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.
121
+
122
+ Make sure to review and revise the ad and verify that all information is accurate before posting it online.
123
+
124
+ *CONCLUSION*
125
+ That's it!
126
+
127
+ By leveraging the power of ChatGPT-4, HR professionals can create job advertisements that stand out and attract top talent.
128
+
129
+ Remember, in the digital age of recruitment, your job ad is your first impression. So make it count!"""
130
+
131
+ UserPrompt_11 = r""""Task: Crafting product update checklists on product updates and new features for customer onboarding
132
+ Task Description: Review the latest product updates and new features, ensuring a comprehensive understanding of their functionalities and benefits.
133
+ Create detailed checklists that outline step-by-step procedures for clients to effectively integrate and utilize these updates and features in their existing systems or processes.
134
+ Ensure the checklists are clear, user-friendly, and tailored to support customers of varying technical proficiency, facilitating smooth onboarding and optimal use of the new product capabilities.
135
+ Additional instructions: The tutorial is aimed at employees in a Client Support department."
136
+
137
+ HOOK:
138
+ If you're in client support, you know how tricky it can be to explain new product features to a wide range of customers. Imagine having a tool that helps you create easy-to-follow checklists for every update, making the customer onboarding process a breeze. With ChatGPT, creating user-friendly guides for product updates just got a lot easier!
139
+
140
+ TITLE:
141
+ Create Easy-to-Follow Product Update Checklists with ChatGPT: A Guide for Client Support Teams
142
+
143
+ INTRO:
144
+ Hello there, Client Support team members! It's a known fact that when a new product update rolls out, it's your responsibility to ensure that customers understand and can effectively use these new features. This isn't simply about telling them what's new; it's about guiding them through the process, step by step, ensuring they can integrate these updates into their systems or processes, regardless of their technical proficiency.
145
+
146
+ But how do you create clear, user-friendly checklists that cater to customers with varying levels of expertise? That's where ChatGPT comes in. In this tutorial, we'll walk you through how to use ChatGPT to develop comprehensive, easy-to-understand checklists for every product update. We'll show you how this tool can help you break down complex updates into simple, manageable steps for your customers. Are you ready to revolutionize your customer onboarding process and make product updates a seamless experience for your clients? Let's get started!
147
+ """
148
+
149
+ AssistantPrompt_11 = r""""*LEARNING OBJECTIVES SUMMARY*
150
+ By the end of this tutorial, you will be able to:
151
+
152
+ 1. Use ChatGPT to interpret product updates and new features
153
+ 2. Generate detailed, user-friendly checklists for product onboarding
154
+
155
+ *LEARNING OBJECTIVE 1*
156
+ Firstly, let's get a comprehensive understanding of product updates and their benefits.
157
+
158
+ Product updates can range from minor tweaks to significant overhauls. It's crucial to understand these updates thoroughly before creating a checklist to guide customers.
159
+
160
+ Suppose we have a recent update for an email marketing software called 'MailBlitz'. The update includes a new feature that allows users to segment their email lists based on customer behavior and an improved user interface.
161
+
162
+ To get a comprehensive understanding, feed this information to ChatGPT.
163
+
164
+ Type into the ChatGPT:
165
+ "You are a software expert. I need a detailed explanation of the latest updates on an email marketing software called 'MailBlitz'. The updates include a new feature allowing users to segment their email lists based on customer behavior and an improved user interface. Ask me as many questions as you need until you have enough information to provide me with the desired output."
166
+
167
+ Then, press the send button.
168
+
169
+ ChatGPT will ask relevant questions until it has enough information to provide a detailed explanation.
170
+
171
+ *LEARNING OBJECTIVE 2*
172
+ Next, let's move on to create a user-friendly checklist for these updates. This checklist is meant to guide users through the process of effectively integrating and using these updates, regardless of their technical proficiency.
173
+
174
+ Type into the ChatGPT:
175
+ "Now that we understand the update, let's create a step-by-step checklist to help users integrate these updates into their systems. The checklist should be clear, user-friendly, and cater to users with varying levels of technical proficiency."
176
+
177
+ Then, press the send button.
178
+
179
+ ChatGPT will generate a comprehensive checklist, breaking down complex procedures into simple, digestible steps.
180
+
181
+ *CONCLUSION*
182
+ And there you have it! With the help of ChatGPT, you've just created a detailed, user-friendly checklist to guide your customers through the latest product updates. Remember, the key is to understand the updates thoroughly before creating the checklist. Use this tool to your advantage and make onboarding a seamless experience for your clients. Happy onboarding!"""
183
+
184
+
185
+ # Define messages for stepTwo
186
+ SystemPrompt_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.
187
+
188
+ Given 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:
189
+
190
+ - Learning Objectives Summary
191
+ - Learning Objective 1
192
+ - Learning Objective 2
193
+ - Learning Objective 3 (this third one is optional)
194
+ - Conclusion
195
+
196
+ The 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.
197
+
198
+ Make sure to also include:
199
+ - the exact prompt(s) the user needs to type into ChatGPT;
200
+ - realistic sample data for a case study, if applicable."""
201
+
202
+ UserPrompt_20 = r"""Topic of the tutorial: How to create a Job Ad with ChatGPT.
203
+ Additional instructions: Use digital marketing manager as an example role.
204
+
205
+ *HOOK*
206
+ If you want your job ads to be found by the right candidates, you have to incorporate the right SEO-friendly keywords.
207
+
208
+ But how do you accomplish this without a lot of experience in Search Engine Optimization?
209
+
210
+ Well, with ChatGPT.
211
+
212
+ *TITLE*
213
+ Create a Job Ad with ChatGPT
214
+
215
+ *INTRO*
216
+ In this digital age, getting your job ad to stand out amongst the rest is crucial to finding the best candidates.
217
+
218
+ Today, 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."""
219
+
220
+ AssistantPrompt_20 = r"""*LEARNING OBJECTIVES SUMMARY*
221
+ You will learn how to:
222
+ - Create an ideal job description
223
+ - Extract SEO-friendly keywords
224
+ - Craft a job ad
225
+
226
+ Let's dive right in!
227
+
228
+ *LEARNING OBJECTIVE 1*
229
+ You can't create the perfect job ad without first creating the job description.
230
+
231
+ Creating 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.
232
+
233
+ To 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.
234
+
235
+ 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.
236
+
237
+ Let's say you've been tasked to recruit a 'Digital Marketing Manager'.
238
+
239
+ Gather as much information as you can on the specifics of this job from the person that made the request.
240
+
241
+ For this tutorial, we’ll be using the following sample information.
242
+
243
+ The job title is "Digital marketing manager."
244
+
245
+ Here'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:
246
+ - overseeing online marketing campaigns and other digital projects to optimize online brand presence and boost revenue.
247
+ - managing a team of 3 digital marketers."
248
+
249
+ The 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."
250
+
251
+ Now, we're ready to write our prompt.
252
+
253
+ Type:
254
+ “You are a recruiter. Create a job description for a digital marketing manager.
255
+
256
+ Here are some additional details to consider when writing the job description:”
257
+
258
+ Then, paste the details you gathered previously.
259
+
260
+ Then press the send button.
261
+
262
+
263
+ ChatGPT wrote some basic details, the overview of the role, and key responsibilities of the role.
264
+
265
+ It also included [basic and preferred qualifications], [what's in it for the applicant], and [more instructions].
266
+
267
+ Make sure to review and revise this job description so it effectively communicates your expectations.
268
+
269
+ *LEARNING OBJECTIVE 2*
270
+ With this description, we can proceed to extract keywords which potential candidates might use when searching for this job.
271
+
272
+ Keywords are important because they make your job ad discoverable. The best keywords should resonate with the job seekers' search behavior.
273
+
274
+ Let's get keywords from ChatGPT.
275
+
276
+ Type:
277
+ "Provide keywords related to the role of Digital Marketing Manager based on the description you've provided me."
278
+
279
+ Then, press the send message button.
280
+
281
+ ChatGPT came up with a couple of keywords that we can use when posting our final job ad.
282
+
283
+ We can also incorporate these keywords into the job ad itself.
284
+
285
+ *LEARNING OBJECTIVE 3*
286
+ With our description and keywords in hand, let's craft a job ad that integrates them both seamlessly.
287
+
288
+ Type:
289
+ "Using the job description and the keywords you've provided, draft a job ad for a Digital Marketing Manager."
290
+
291
+ Then, press the send button.
292
+
293
+ Here's the response.
294
+
295
+
296
+ ChatGPT 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.
297
+
298
+ Make sure to review and revise the ad and verify that all information is accurate before posting it online.
299
+
300
+ *CONCLUSION*
301
+ That's it!
302
+
303
+ By leveraging the power of ChatGPT-4, HR professionals can create job advertisements that stand out and attract top talent.
304
+
305
+ Remember, in the digital age of recruitment, your job ad is your first impression. So make it count!"""
306
+
307
+
308
+ # Function to make API call
309
+ def api_call(messages, temperature=0.9, model="gpt-4-1106-preview"):
310
+ return openai.ChatCompletion.create(
311
+ messages=messages,
312
+ temperature=temperature,
313
+ model=model
314
+ ).choices[0].message.content
315
+
316
+
317
+ # Function to be called by Gradio interface
318
+ def process_inputs(EPA_title, Task_Description, Extra_input, Department):
319
+ # Check if EPA_title is empty
320
+ if not EPA_title:
321
+ return manual
322
+ if not Extra_input:
323
+ stepOne = [
324
+ {"role": "system", "content": SystemPrompt_10},
325
+ {"role": "user", "content": UserPrompt_10},
326
+ {"role": "assistant", "content": AssistantPrompt_10},
327
+ {"role": "user", "content": UserPrompt_11},
328
+ {"role": "assistant", "content": AssistantPrompt_11},
329
+ {"role": "user", "content": f"""Task: {EPA_title}.
330
+ Task Description: {Task_Description}
331
+ Additional Instructions: The tutorial should be aimed at employees in a {Department} department."""}
332
+ ]
333
+ Script_1st_half = api_call(stepOne, 0.7)
334
+
335
+ stepTwo = [
336
+ {"role": "system", "content": SystemPrompt_20},
337
+ {"role": "user", "content": UserPrompt_20},
338
+ {"role": "assistant", "content": AssistantPrompt_20},
339
+ {"role": "user", "content": f"""Task: {EPA_title}.
340
+ Task Description: {Task_Description}
341
+ Additional Instructions: The tutorial should be aimed at employees in a {Department} department."""}
342
+ ]
343
+ Script_2nd_half = api_call(stepTwo, 0.7)
344
+ Script_complete = Script_1st_half + "\n\n" + Script_2nd_half
345
+ return Script_complete
346
+
347
  else:
348
+ # Step 1: User input and first API call ~5secs
349
+ stepOne = [
350
+ {"role": "system", "content": SystemPrompt_10},
351
+ {"role": "user", "content": UserPrompt_10},
352
+ {"role": "assistant", "content": AssistantPrompt_10},
353
+ {"role": "user", "content": UserPrompt_11},
354
+ {"role": "assistant", "content": AssistantPrompt_11},
355
+ {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}
356
+ Additional instructions: {Extra_input}
357
+ The tutorial is aimed at employees in a {Department} department."""}
358
+ ]
359
+ Script_1st_half = api_call(stepOne, 0.7)
360
+
361
+ stepTwo = [
362
+ {"role": "system", "content": SystemPrompt_20},
363
+ {"role": "user", "content": UserPrompt_20},
364
+ {"role": "assistant", "content": AssistantPrompt_20},
365
+ {"role": "user", "content": f"""Topic of the tutorial: {EPA_title}
366
+ Additional instructions: {Extra_input}
367
+ The tutorial is aimed at employees in a {Department} department.
368
+
369
+ {Script_1st_half}"""}
370
+ ]
371
+ Script_2nd_half = api_call(stepTwo, 0.7)
372
+ Script_complete = Script_1st_half + "\n\n" + Script_2nd_half
373
+ return Script_complete
374
+
375
+ departments = {
376
+ "3D": "3D Modeling", # Label and value differ
377
+ "Client Support": "Client Support",
378
+ "Data Entry & Back Office": "Data Entry & Back Office",
379
+ "Education Administration (ENI)": "Education Administration", # Label and value differ
380
+ "Finance": "Finance",
381
+ "Marketing": "Marketing",
382
+ "HR": "HR",
383
+ "IT": "IT",
384
+ "Legal": "Legal",
385
+ "Product Management": "Product Management",
386
+ "Project Management/Coordination": "Project Management/Coordination",
387
+ "Process Management": "Process Management",
388
+ "QA": "QA",
389
+ "R&D": "R&D",
390
+ "Sales": "Sales",
391
+ "Software": "Software",
392
+ "Video Production": "Video Production",
393
+ "Visual Management": "Visual Management"
394
+ }
395
+
396
+ # Create the Gradio interface
397
+ iface = gr.Interface(
398
+ fn=process_inputs,
399
+ inputs=[
400
+ gr.Textbox(lines=2, label='EPA title Here... (use the phrasing: "How to do X using ChatGPT")'),
401
+ gr.Textbox(lines=2, label='Task Description'),
402
+ gr.Textbox(lines=2, label='Extra input Here... (optional, put any extra requirements or relevant context)'),
403
+ gr.Dropdown(choices=departments, label="Select Team", searchable=True)
404
+ ],
405
+ outputs=gr.Textbox(label="Script", show_copy_button=True)
406
+ )
407
+
408
+ iface.launch(share=True)
409
+ iface.launch()