Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio
|
3 |
+
|
4 |
+
openai.api_key = "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"
|
5 |
+
|
6 |
+
messages = [{"role": "system", "content": "You are a Chatbot who only talks related to subject mathematics"}]
|
7 |
+
|
8 |
+
def CustomChatGPT(user_input):
|
9 |
+
messages.append({"role": "user", "content": user_input})
|
10 |
+
response = openai.ChatCompletion.create(model = "gpt-3.5-turbo", messages = messages)
|
11 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
12 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
13 |
+
return ChatGPT_reply
|
14 |
+
|
15 |
+
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Doctor")
|
16 |
+
demo.launch()
|