ai / app.py
thebetterindia's picture
Update app.py
221beb1
raw
history blame
1.04 kB
import openai
import gradio as gr
openai.api_key = "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"
messages = [
{"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."},
]
def chatbot(input):
if input:
messages.append({"role": "user", "content": input})
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages
)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
return reply
inputs = gr.inputs.Textbox(lines=7, label="Chat with The Better AI")
outputs = gr.outputs.Textbox(label="Reply")
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="The Better AI",
description="Ask anything you want",
theme="compact").launch()