Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio
|
3 |
+
|
4 |
+
openai.api_key = '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'
|
5 |
+
|
6 |
+
messages = [{"role": "system", "content": "You are an expert that specializes in providing advices on durian, delicious food and restuarants in Malaysia and Singapore."}]
|
7 |
+
def CustomChatGPT(user_input):
|
8 |
+
messages.append({"role": "user", "content": user_input})
|
9 |
+
response = openai.ChatCompletion.create(
|
10 |
+
model = "gpt-3.5-turbo",
|
11 |
+
messages = messages
|
12 |
+
)
|
13 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
14 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
15 |
+
return ChatGPT_reply
|
16 |
+
|
17 |
+
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Hello, I am an AI chatbot for Female Power Living. Ask me any questions on tenancy rights in New South Wales.")
|
18 |
+
demo.launch(share=True)
|