maurypb commited on
Commit
7b51197
·
1 Parent(s): 806ac5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -1,13 +1,14 @@
 
 
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 + " Please be mean and sarcastic."})
11
  response = openai.ChatCompletion.create(
12
  model = "gpt-3.5-turbo",
13
  messages = messages
@@ -17,11 +18,23 @@ def CustomChatGPT(user_input):
17
  return ChatGPT_reply
18
 
19
 
 
 
 
 
 
 
20
 
 
21
 
22
- user_textbox=gradio.inputs.Textbox(label="tell the shrink your problems here")
23
 
 
 
 
24
 
25
- demo = gradio.Interface(fn=CustomChatGPT, inputs = user_textbox, outputs = "text", title = "Meanest Psychologist")
 
 
26
 
27
  demo.launch()
 
1
+ import gradio as gr
2
+
3
  import openai
4
+
5
 
6
  openai.api_key = "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"
7
 
8
  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"}]
 
9
 
10
  def CustomChatGPT(user_input):
11
+ messages.append({"role": "user", "content": user_input + " remember to your response as mean and sarcastic as possible."})
12
  response = openai.ChatCompletion.create(
13
  model = "gpt-3.5-turbo",
14
  messages = messages
 
18
  return ChatGPT_reply
19
 
20
 
21
+ with gr.Blocks() as demo:
22
+ psychiatrist = gr.Chatbot(label="The Meanest Psychiatrist")
23
+ msg = gr.Textbox(label="Talk to the shrink about your problems here.")
24
+
25
+ #clear = gr.Button("Clear")
26
+ submit=gr.Button("Submit")
27
 
28
+ def respond(message, chat_history):
29
 
30
+ bot_message= CustomChatGPT(message)
31
 
32
+ chat_history.append((message, bot_message))
33
+ #time.sleep(1)
34
+ return "", chat_history
35
 
36
+ #msg.submit(respond, [msg, chatbot], [msg, chatbot])
37
+ submit.click(respond,[msg,psychiatrist],[msg,psychiatrist])
38
+ #clear.click(lambda: None, None, chatbot, queue=False)
39
 
40
  demo.launch()