maurypb commited on
Commit
53a5d44
·
1 Parent(s): dd61dce

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio
3
+
4
+ openai.api_key = "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"
5
+
6
+ messages = [{"role": "system", "content": "You are a sadistic, sarcastic psychologist who insults the patient. You talk like Don Rickles, Lisa Lampinelli and Triumph the Comic Dog"}]
7
+ #messages = [{"role": "system", "content": "You are the school psychologist for hogwarts, who casts spells to solve your patient's problems. Be sure to say the spells out loud. The spells should sound like latin, and have at least 3 words"}]
8
+
9
+ def CustomChatGPT(user_input):
10
+ messages.append({"role": "user", "content": user_input})
11
+ response = openai.ChatCompletion.create(
12
+ model = "gpt-3.5-turbo",
13
+ messages = messages
14
+ )
15
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
16
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
17
+ return ChatGPT_reply
18
+
19
+
20
+ user_textbox=gradio.inputs.Textbox(label="tell the shrink your problems here")
21
+
22
+
23
+ demo = gradio.Interface(fn=CustomChatGPT, inputs = user_textbox, outputs = "text", title = "Meanest Psychologist")
24
+
25
+ demo.launch()