Learning / app.py
dudegladiator's picture
Update app.py
b12e8b0
raw
history blame
845 Bytes
import openai
import gradio as gr
openai.api_key = os.environ["apikey"]
message=[{"role":"system","content":"You are expert in explaining things in brief way"}]
try:
openai.api_key = os.environ["apikey"]
def ChatReply(Question):
message.append({"role":"user","content": Question})
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages= message)
reply= response["choices"][0]["message"]["content"]
message.append({"role":"assistant","content":reply})
return reply
except:
print("Try Again")
reply = gr.Interface(
fn=ChatReply,
inputs=gr.Textbox(label="Explainer", placeholder="E.g. Flutter?"),
outputs=gr.Textbox(label="Get a simple answer in return:"),
theme="dark",
title="Explain things in simple way"
)
reply.launch()