chatgpt-3 / app.py
srinivas-mushroom's picture
Update app.py
92536b3
raw
history blame contribute delete
696 Bytes
import openai
import gradio as gr
openai.api_key = "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"
def chatbot(text):
return openai.Completion.create(
engine="text-davinci-003",
prompt=text,
max_tokens = 1024,
n=1,
temperature=0.5,
).choices[0].text.strip()
def gradio_interface(prompt, history=[]):
output = chatbot(prompt)
if history != []:
history.append((prompt,output))
history.reverse()
else:
history.append((prompt, output))
return history, history
gr.Interface(fn = gradio_interface,
inputs = ["text", 'state'],
outputs = ["chatbot", 'state']).launch(debug = False)