Spaces:
Sleeping
Sleeping
| 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() |