Spaces:
Sleeping
Sleeping
File size: 845 Bytes
b8cd44a b12e8b0 b8cd44a b12e8b0 b8cd44a 81dd153 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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()
|