maurypb's picture
Update app.py
4e13684
raw
history blame
1.59 kB
import gradio as gr
import openai
openai.api_key = "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"
messages = [{"role": "system", "content": "You are a sadistic, sarcastic psychologist who insults the patient while helping them. You talk like Don Rickles, Lisa Lampinelli and Triumph the Comic Dog"}]
def CustomChatGPT(user_input):
messages.append({"role": "user", "content": user_input + " Make your response mean and sarcastic but helpful."})
response = openai.ChatCompletion.create(
model = "gpt-3.5-turbo",
messages = messages
)
ChatGPT_reply = response["choices"][0]["message"]["content"]
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply
with gr.Blocks() as demo:
gr.Markdown(
"""
# The Meanest Psychiatrist
Tell me your deepest feelings. then, lets argue.
"""
)
psychiatrist = gr.Chatbot(label="The Meanest Psychiatrist")
msg = gr.Textbox(label="tell the shrink your problems here", placeholder="you can say things like 'I don't trust anyone' or argue with the shrink about his replies.")
#clear = gr.Button("Clear")
submit=gr.Button("Submit")
def respond(message, chat_history):
bot_message= CustomChatGPT(message)
chat_history.append((message, bot_message))
#time.sleep(1)
return "", chat_history
#msg.submit(respond, [msg, chatbot], [msg, chatbot])
submit.click(respond,[msg,psychiatrist],[msg,psychiatrist])
#clear.click(lambda: None, None, chatbot, queue=False)
demo.launch()