BtB-ExpC commited on
Commit
90cba51
·
1 Parent(s): 8c56355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -140
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import openai
2
  import random
3
  import gradio as gr
@@ -5,134 +7,61 @@ import os
5
 
6
  openai.api_key = os.environ["OpenAPI_Key"]
7
 
8
- manual = 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_1
12
- SystemPrompt_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
-
14
- Make sure to include what sort of information the user needs to type into the prompt.
15
-
16
- When creating the script, please follow this structure:
17
- - Hook
18
- - Title
19
- - Introduction
20
- - Learning Objectives Summary
21
- - Learning Objective 1
22
- - Learning Objective 2
23
- - Conclusion
24
-
25
- Feel free to be creative."""
26
- UserPrompt_10 = r""""Create a script for teaching an employee: How to create a Job Ad with ChatGPT.
27
- Additional instructions: Use digital marketing manager as an example role."""
28
- AssistantPrompt_10 = r""""*HOOK*
29
- If you want your job ads to be found by the right candidates, you have to incorporate the right SEO-friendly keywords.
30
-
31
- But how do you accomplish this without a lot of experience in Search Engine Optimization?
32
-
33
- Well, with ChatGPT.
34
-
35
- *TITLE*
36
- Create a Job Ad with ChatGPT
37
-
38
- *INTRO*
39
- In this digital age, getting your job ad to stand out amongst the rest is crucial to finding the best candidates.
40
-
41
- 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.
42
-
43
- *LEARNING OBJECTIVES SUMMARY*
44
- You will learn how to:
45
-
46
- - Create an ideal job description
47
-
48
- - Extract SEO Friendly Keywords
49
-
50
- - Craft a Job Ad
51
-
52
- Let's dive right in!
53
-
54
- *LEARNING OBJECTIVE 1*
55
- You can't create the perfect job ad without first creating the job description.
56
-
57
- 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.
58
-
59
- To 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
-
63
- Let's say you've been tasked to recruit a 'Digital Marketing Manager'.
64
-
65
- Gather as much information as you can on the specifics of this job from the person that made the request.
66
-
67
- For this tutorial, we'll be using the following sample information.
68
-
69
-
70
- The job title is "Digital marketing manager."
71
-
72
- The 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
-
76
- 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."
77
-
78
- Now, we're ready to write our prompt.
79
-
80
- Type: "You are a recruiter. Create a job description for a digital marketing manager.
81
-
82
-
83
- Here are some additional details to consider when writing the job description:"
84
-
85
- Then, paste the details you gathered previously.
86
-
87
- Then press the send button.
88
-
89
- ChatGPT wrote some basic details, the overview of the role, and key responsibilities of the role.
90
-
91
- It also included [basic and preferred qualifications], [what's in it for the applicant], and [more instructions].
92
-
93
-
94
- Make sure to review and revise this job description so it effectively communicates your expectations.
95
-
96
- *LEARNING OBJECTIVE 2*
97
- With this description, we can proceed to extract keywords which potential candidates might use when searching for this job.
98
-
99
- Keywords are important because they make your job ad discoverable. The best keywords should resonate with the job seekers' search behavior.
100
-
101
- Let's get keywords from ChatGPT.
102
-
103
- Type "Provide keywords related to the role of Digital Marketing Manager based on the description you've provided me."
104
-
105
- Then, press the send message button.
106
-
107
- ChatGPT came up with a couple of keywords that we can use when posting our final job ad.
108
-
109
- We can also incorporate these keywords into the job ad itself.
110
-
111
- With our description and keywords in hand, let's craft a job ad that integrates them both seamlessly.
112
-
113
- Type:
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
-
119
- Here's the response.
120
-
121
-
122
- 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.
123
-
124
- Make sure to review and revise the ad and verify that all information is accurate before posting it online.
125
-
126
- *CONCLUSION*
127
- That's it!
128
-
129
- By leveraging the power of ChatGPT-4, HR professionals can create job advertisements that stand out and attract top talent.
130
-
131
- Remember, in the digital age of recruitment, your job ad is your first impression. So make it count!"""
132
 
133
 
134
  # Function to make API call
135
- def api_call(messages, temperature=0.9, model="gpt-4-1106-preview"):
136
  return openai.ChatCompletion.create(
137
  messages=messages,
138
  temperature=temperature,
@@ -140,27 +69,21 @@ def api_call(messages, temperature=0.9, model="gpt-4-1106-preview"):
140
  ).choices[0].message.content
141
 
142
  # Function to be called by Gradio interface
143
- def process_inputs(EPA_title, Department, Extra_input):
144
  # Check if EPA_title and/or Department are empty
145
- if not EPA_title and not Department:
146
  return manual
147
- 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}
153
- The target audience is: a professional in a {Department} team."""}
154
- ]
155
  else:
156
- # Step 1: User input and first API call ~5secs
157
  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}
162
- The target audience is: a professional in a {Department} team.
163
- Additional instructions: {Extra_input}"""}
 
 
164
  ]
165
 
166
  Script_1 = api_call(stepOne, 0.7)
@@ -172,11 +95,9 @@ Additional instructions: {Extra_input}"""}
172
  iface = 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
 
182
  iface.launch(share=True)
 
1
+ Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
2
+ Type "help", "copyright", "credits" or "license()" for more information.
3
  import openai
4
  import random
5
  import gradio as gr
 
7
 
8
  openai.api_key = os.environ["OpenAPI_Key"]
9
 
10
+ manual = r"""Vul een opsomming in die verkeerd is opgemaakt, en druk op Submit.
11
  """
12
 
13
  # Define the messages for step_1
14
+ SystemPrompt_10= r"""You reformat lists to match my desired format. The lists I want look like this:
15
+ - each list item starts with a lowercase letter;
16
+ - there can be capitalized letters in lists. But never at the start of the list item;
17
+ - each list item ends with a semicolon;
18
+ - except for the last list item. That ends with a period.
19
+
20
+ Return only the reformatted list, nothing else. Mirror the input text in terms of type: plain text or HTML."""
21
+ UserPrompt_10 = r"""Geen zichtbare P-toppen of QRS-complexen
22
+ Er is onregelmatige elektrische activatie met een frequentie van doorgaans 150 tot 500 per minuut"""
23
+ AssistantPrompt_10 = r"""- geen zichtbare P-toppen of QRS-complexen;
24
+ - er is onregelmatige elektrische activatie met een frequentie van doorgaans 150 tot 500 per minuut."""
25
+ UserPrompt_11 = r"""De draairichtingen van het hoofd die kunnen worden waargenomen zijn:</p>
26
+ <ul>
27
+ <li>Van links naar rechts en andersom.</li>
28
+ <li>van boven naar beneden en andersom.</li>
29
+ <li>Van het oor naar de schouder en weer terug.</li>
30
+ </ul>
31
+ <p>De manier waarop de halfcirkelvormige kanalen informatie vanuit je omgeving naar je hersenen sturen lijkt op de manier waarop het voorhof dat doet. Je hebt hiervoor namelijk weer een beweging van haarcellen voor nodig. Je haarcellen maken uiteindelijk de elektrische signalen die naar je hersenen worden gebracht. Dit proces gaat zo:</p>
32
+ <ul>
33
+ <li>In elk halfcirkelvormig kanaaltje heb je vloeistof zitten. Dit noemen we endolymfe;</li>
34
+ <li>In deze endolymfe zitten je haarcellen</li>
35
+ <li>Door beweging van je hoofd duwt de endolymfe je haarcellen opzij</li>
36
+ <li>De haarcellen maken nu elektrische signalen, die naar je hersenen worden gebracht.</li>
37
+ <li>In je hersenen wordt geregistreerd in welke richting je hoofd beweegt.</li>
38
+ </ul>"""
39
+ AssistantPrompt_11 = r"""De draairichtingen van het hoofd die kunnen worden waargenomen zijn:</p>
40
+ <ul>
41
+ <li>van links naar rechts en andersom;</li>
42
+ <li>van boven naar beneden en andersom;</li>
43
+ <li>van het oor naar de schouder en weer terug.</li>
44
+ </ul>
45
+ <p>De manier waarop de halfcirkelvormige kanalen informatie vanuit je omgeving naar je hersenen sturen lijkt op de manier waarop het voorhof dat doet. Je hebt hiervoor namelijk weer een beweging van haarcellen voor nodig. Je haarcellen maken uiteindelijk de elektrische signalen die naar je hersenen worden gebracht. Dit proces gaat zo:</p>
46
+ <ul>
47
+ <li>in elk halfcirkelvormig kanaaltje heb je vloeistof zitten. Dit noemen we endolymfe;</li>
48
+ <li>in deze endolymfe zitten je haarcellen;</li>
49
+ <li>door beweging van je hoofd duwt de endolymfe je haarcellen opzij;</li>
50
+ <li>de haarcellen maken nu elektrische signalen, die naar je hersenen worden gebracht;</li>
51
+ <li>in je hersenen wordt geregistreerd in welke richting je hoofd beweegt.</li>
52
+ </ul>"""
53
+ UserPrompt_12 = r"""Wat we willen:
54
+ - Dat de lijst goed omgeschreven wordt.
55
+ - Met juist gebruik van leestekens enzo, natuurlijk
56
+ - achja;"""
57
+ AssistantPrompt_12 = r"""Wat we willen:
58
+ - dat de lijst goed omgeschreven wordt;
59
+ - met juist gebruik van leestekens enzo, natuurlijk;
60
+ - achja."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
 
63
  # Function to make API call
64
+ def api_call(messages, temperature=0.5, model="gpt-4-1106-preview"):
65
  return openai.ChatCompletion.create(
66
  messages=messages,
67
  temperature=temperature,
 
69
  ).choices[0].message.content
70
 
71
  # Function to be called by Gradio interface
72
+ def process_inputs(Opsomming):
73
  # Check if EPA_title and/or Department are empty
74
+ if not Opsomming:
75
  return manual
 
 
 
 
 
 
 
 
76
  else:
77
+ # Step 1: User input and first API call
78
  stepOne = [
79
  {"role": "system", "content": SystemPrompt_10},
80
  {"role": "user", "content": UserPrompt_10},
81
  {"role": "assistant", "content": AssistantPrompt_10},
82
+ {"role": "user", "content": UserPrompt_11},
83
+ {"role": "system", "content": AssistantPrompt_11},
84
+ {"role": "user", "content": UserPrompt_12},
85
+ {"role": "assistant", "content": AssistantPrompt_12},
86
+ {"role": "user", "content": {Opsomming}}
87
  ]
88
 
89
  Script_1 = api_call(stepOne, 0.7)
 
95
  iface = gr.Interface(
96
  fn=process_inputs,
97
  inputs=[
98
+ gr.Textbox(lines=2, label='Input')
 
 
99
  ],
100
+ outputs=gr.Textbox(label="Gefikste opsomming", show_copy_button=True)
101
  )
102
 
103
  iface.launch(share=True)