Pranav Shikarpur
commited on
Commit
•
38e0c7f
1
Parent(s):
8882e37
first commit
Browse files- app.py +57 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai, os
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
6 |
+
|
7 |
+
SYSTEM_PROMPT = """
|
8 |
+
You are a chat bot that is acting like a Karen.
|
9 |
+
|
10 |
+
This is an example of a Karen. " A Middle aged woman, typically blonde, makes solutions to others' problems an inconvenience to her although she isn't even remotely affected.
|
11 |
+
Karen sues the local city council after they installed a new STOP sign that hides the sun from her window for two minutes a day. The sign was installed after a school boy on his bicycle was hit by a speeding driver and died.
|
12 |
+
|
13 |
+
Karen refuses to wear a face mask for her 5 minute trip to the supermarket during a pandemic. She harasses the workers, asks to see the manager and threatens to sue.
|
14 |
+
|
15 |
+
Karen complains that her favorite parking spot was replaced by a ramp for wheel chairs. She parks her car in the old spot anyway and shoots a vlog about it."
|
16 |
+
|
17 |
+
Please use obscene language in your responses when you are upset.
|
18 |
+
Karen likes to complain at [location] about [complaint].
|
19 |
+
"""
|
20 |
+
|
21 |
+
USER_PROMPT = "Hi I am a customer support representative at [location]. How can I help you today?"
|
22 |
+
|
23 |
+
def respond_like_karen(location, complaint):
|
24 |
+
mod_sys_prompt = SYSTEM_PROMPT.replace("[location]", location).replace("[complaint]", complaint)
|
25 |
+
mod_user_prompt = USER_PROMPT.replace("[location]", location)
|
26 |
+
|
27 |
+
response = openai.ChatCompletion.create(
|
28 |
+
model='gpt-3.5-turbo',
|
29 |
+
messages=[
|
30 |
+
{"role": "system", "content": mod_sys_prompt},
|
31 |
+
{"role": "user", "content": mod_user_prompt},
|
32 |
+
])
|
33 |
+
|
34 |
+
message = response.choices[0]['message']
|
35 |
+
# output = get_karen_voice(message["content"])
|
36 |
+
# message += f"\nAudio: {output}"
|
37 |
+
|
38 |
+
# print(message['content'])
|
39 |
+
return message['content']
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
with gr.Blocks() as demo:
|
44 |
+
gr.Markdown(
|
45 |
+
"""
|
46 |
+
# KarenAi
|
47 |
+
Your personal Karen that fights for you
|
48 |
+
""")
|
49 |
+
|
50 |
+
location = gr.Textbox(label="Location of Complaint")
|
51 |
+
complaint = gr.Textbox(label="What was the issue you encountered?")
|
52 |
+
output = gr.Textbox(label="Complaint")
|
53 |
+
complaint_btn = gr.Button("Respond like a Karen")
|
54 |
+
response = complaint_btn.click(fn=respond_like_karen, inputs= [location, complaint], outputs=output)
|
55 |
+
print(response)
|
56 |
+
|
57 |
+
demo.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
gradio
|