Spaces:
Runtime error
Runtime error
import os | |
import gradio as gr | |
import openai | |
def gpt(api_key): | |
openai.api_key = api_key | |
completion = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[{"role": "user", "content": "Generate a fake news story"}] | |
) | |
return completion.choices[0].message.content | |
demo = gr.Interface(fn=gpt, inputs="text", outputs="text") | |
demo.launch() |