thebetterindia commited on
Commit
980a65f
1 Parent(s): 65bc30c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+
4
+ openai.api_key = "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"
5
+
6
+ messages = [
7
+ {"role": "system", "content": "You are an AI assistant that only gives responses from the website www.thebetterindia.com and you help people make decisions about how to make a difference in others' lives. You also provide the relevant links from that website as part of your answers."},
8
+ ]
9
+
10
+ def chatbot(input):
11
+ if input:
12
+ messages.append({"role": "user", "content": input})
13
+ chat = openai.ChatCompletion.create(
14
+ model="gpt-3.5-turbo", messages=messages
15
+ )
16
+ reply = chat.choices[0].message.content
17
+ messages.append({"role": "assistant", "content": reply})
18
+ return reply
19
+
20
+ inputs = gr.inputs.Textbox(lines=7, label="Chat with The Better AI")
21
+ outputs = gr.outputs.Textbox(label="Reply")
22
+
23
+ gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="The Better AI",
24
+ description="Ask anything you want",
25
+ theme="compact").launch(share=True)