Spaces:
Build error
Build error
File size: 713 Bytes
064a96f |
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 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()
|