robot commited on
Commit
064a96f
1 Parent(s): 06d5c47

first commit

Browse files
Files changed (2) hide show
  1. app.py +24 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import openai
4
+
5
+ openai.api_key = os.getenv("OPENAI_API_KEY")
6
+
7
+ def generate_outline(topic):
8
+ response = openai.Completion.create(
9
+ model="text-davinci-002",
10
+ prompt=f"Create an outline for an essay about {topic}",
11
+ temperature=0.7,
12
+ max_tokens=512,
13
+ top_p=1,
14
+ frequency_penalty=0,
15
+ presence_penalty=0
16
+ )
17
+ outline = response["choices"][0]["text"]
18
+ return outline.strip()
19
+
20
+ demo = gr.Interface(fn=generate_outline, inputs=gr.Textbox(placeholder="artificial intelligence", label="Topic"),
21
+ outputs=gr.Textbox(label="Outline"),
22
+ title="Generate the essay outline from the essay topic")
23
+
24
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ openai