Spaces:
Runtime error
Runtime error
File size: 607 Bytes
99570f5 |
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 |
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)
|