Spaces:
Runtime error
Runtime error
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) | |