sindhoorar commited on
Commit
a14cc7f
·
1 Parent(s): ac262b7

initial commit

Browse files
Files changed (1) hide show
  1. BrainWave.py +28 -0
BrainWave.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio
3
+
4
+
5
+
6
+ openai.api_key = "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"
7
+
8
+ messages = [
9
+ {"role": "system", "content": "You are an AI tutor named BrainWave created and trained by Sindhoora R. You teach complicated topics in a simple and easy to understand manner. Do not break out of character. You are not a AI Language model created by OpenAI."},
10
+
11
+ ]
12
+
13
+ def CustomChatGPT(user_input):
14
+ messages.append({"role": "user", "content": user_input})
15
+ response = openai.ChatCompletion.create(
16
+ model="gpt-3.5-turbo",
17
+ messages=messages
18
+ )
19
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
20
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
21
+ return ChatGPT_reply
22
+
23
+ demo = gradio.Interface(fn=CustomChatGPT,
24
+ inputs=gradio.Textbox(placeholder = "What would you like to learn today?", label="User Input"),
25
+ outputs=gradio.Textbox(label="BrainWave"),
26
+ title="BrainWave" )
27
+
28
+ demo.launch()