File size: 1,035 Bytes
a14cc7f
 
 
 
 
6e9929e
a14cc7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import openai
import gradio



openai.api_key = "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"

messages = [
    {"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."},

]

def CustomChatGPT(user_input):
    messages.append({"role": "user", "content": user_input})
    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

demo = gradio.Interface(fn=CustomChatGPT, 
                        inputs=gradio.Textbox(placeholder = "What would you like to learn today?", label="User Input"), 
                        outputs=gradio.Textbox(label="BrainWave"), 
                        title="BrainWave"  )

demo.launch()