ChatBot / app.py
Harsh239's picture
Create app.py
ab28427
raw
history blame
652 Bytes
import openai
import gradio
openai.api_key = "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"
messages = [{"role": "system", "content": "You are a Chatbot who only talks related to subject mathematics"}]
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 = "text", outputs = "text", title = "Doctor")
demo.launch()