Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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"""
|
| 9 |
"""
|
| 10 |
|
| 11 |
# Define the messages for step_1
|
| 12 |
-
SystemPrompt_10
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
-
|
| 20 |
-
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 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.
|
| 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(
|
| 144 |
# Check if EPA_title and/or Department are empty
|
| 145 |
-
if not
|
| 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
|
| 157 |
stepOne = [
|
| 158 |
{"role": "system", "content": SystemPrompt_10},
|
| 159 |
{"role": "user", "content": UserPrompt_10},
|
| 160 |
{"role": "assistant", "content": AssistantPrompt_10},
|
| 161 |
-
{"role": "user", "content":
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
| 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='
|
| 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="
|
| 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)
|