falethera commited on
Commit
1ef89c6
1 Parent(s): 6489299

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
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)