karenai / app.py
Pranav Shikarpur
fix: removed share
4f92225
raw
history blame
2.21 kB
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()