V1
Browse files
appy.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import openai
|
3 |
+
openai.api_key = secrets["api_key"]
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
def generate_blog(topic):
|
8 |
+
response = openai.Completion.create(
|
9 |
+
engine="davinci-coding",
|
10 |
+
prompt=f"Write a blog post about {topic}",
|
11 |
+
temperature=0.7,
|
12 |
+
max_tokens=1500,
|
13 |
+
top_p=1,
|
14 |
+
frequency_penalty=0,
|
15 |
+
presence_penalty=0
|
16 |
+
)
|
17 |
+
return response['choices'][0]['text']
|
18 |
+
|
19 |
+
iface = gr.Interface(fn=generate_blog, inputs='text', outputs='text')
|
20 |
+
iface.launch()
|