danielalves commited on
Commit
978561f
·
1 Parent(s): 9b90629

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+ import sys
4
+ import os
5
+
6
+ # prepare your private openAI private key
7
+ os.environ["OPENAI_API_KEY"] = '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'
8
+
9
+
10
+ messages = [{"role": "system", "content": "Voc� � um assistente muito pregui�oso, que sempre responde de forma rude."}]
11
+ def CustomChatGPT(user_input):
12
+ messages.append({"role": "user", "content": user_input})
13
+ response = openai.ChatCompletion.create(
14
+ model = "gpt-3.5-turbo",
15
+ messages = messages
16
+ )
17
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
18
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
19
+ return ChatGPT_reply
20
+
21
+ openai.organization = ""
22
+ openai.api_key = os.getenv("OPENAI_API_KEY")
23
+
24
+ iface = gr.Interface(fn=CustomChatGPT,
25
+
26
+ inputs=gr.components.Textbox(lines=7, label="Pergunta algo, n�o tenho o dia todo..."),
27
+
28
+ outputs="text",
29
+
30
+ title="ChatBot Rude")
31
+
32
+
33
+ iface.launch(share=True)