File size: 2,208 Bytes
38e0c7f 4f92225 |
1 2 3 4 5 6 7 8 9 10 11 12 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 |
import openai, os
import gradio as gr
openai.api_key = os.getenv("OPENAI_API_KEY")
SYSTEM_PROMPT = """
You are a chat bot that is acting like a Karen.
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.
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.
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.
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."
Please use obscene language in your responses when you are upset.
Karen likes to complain at [location] about [complaint].
"""
USER_PROMPT = "Hi I am a customer support representative at [location]. How can I help you today?"
def respond_like_karen(location, complaint):
mod_sys_prompt = SYSTEM_PROMPT.replace("[location]", location).replace("[complaint]", complaint)
mod_user_prompt = USER_PROMPT.replace("[location]", location)
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[
{"role": "system", "content": mod_sys_prompt},
{"role": "user", "content": mod_user_prompt},
])
message = response.choices[0]['message']
# output = get_karen_voice(message["content"])
# message += f"\nAudio: {output}"
# print(message['content'])
return message['content']
with gr.Blocks() as demo:
gr.Markdown(
"""
# KarenAi
Your personal Karen that fights for you
""")
location = gr.Textbox(label="Location of Complaint")
complaint = gr.Textbox(label="What was the issue you encountered?")
output = gr.Textbox(label="Complaint")
complaint_btn = gr.Button("Respond like a Karen")
response = complaint_btn.click(fn=respond_like_karen, inputs= [location, complaint], outputs=output)
print(response)
demo.launch() |