Spaces:
Runtime error
Runtime error
import gradio as gr | |
import openai | |
openai.api_key = "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" | |
def chatbot(user_input): | |
response = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[{"role": "user", "content": user_input}] | |
) | |
return response.choices[0].message['content'] | |
iface = gr.Interface( | |
chatbot, | |
gr.Textbox(label="User Input"), | |
gr.Textbox(label="Chatbot Response") | |
) | |
iface.launch() | |