chatgpt-3 / app.py
srinivas-mushroom's picture
Rename main.py to app.py
5fbeada
raw history blame
No virus
607 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)
history.append((prompt,output))
return history, history
gr.Interface(fn = gradio_interface,
inputs = ["text", 'state'],
outputs = ["chatbot", 'state']).launch(debug = False, share=True)