Spaces:
Build error
Build error
import gradio as gr | |
import os | |
import openai | |
openai.api_key = os.getenv("OPENAI_API_KEY") | |
def generate_outline(topic): | |
response = openai.Completion.create( | |
model="text-davinci-002", | |
prompt=f"Create an outline for an essay about {topic}", | |
temperature=0.7, | |
max_tokens=512, | |
top_p=1, | |
frequency_penalty=0, | |
presence_penalty=0 | |
) | |
outline = response["choices"][0]["text"] | |
return outline.strip() | |
demo = gr.Interface(fn=generate_outline, inputs=gr.Textbox(placeholder="artificial intelligence", label="Topic"), | |
outputs=gr.Textbox(label="Outline"), | |
title="Generate the essay outline from the essay topic") | |
demo.launch() | |