V2
Browse files- appy.py → app.py +7 -9
appy.py → app.py
RENAMED
@@ -1,20 +1,18 @@
|
|
1 |
import os
|
2 |
import openai
|
3 |
-
openai.api_key =
|
4 |
|
5 |
import gradio as gr
|
6 |
|
7 |
def generate_blog(topic):
|
8 |
response = openai.Completion.create(
|
9 |
-
engine="
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
frequency_penalty=0,
|
15 |
-
presence_penalty=0
|
16 |
)
|
17 |
-
return response['
|
18 |
|
19 |
iface = gr.Interface(fn=generate_blog, inputs='text', outputs='text')
|
20 |
iface.launch()
|
|
|
1 |
import os
|
2 |
import openai
|
3 |
+
openai.api_key = os.environ["api"]
|
4 |
|
5 |
import gradio as gr
|
6 |
|
7 |
def generate_blog(topic):
|
8 |
response = openai.Completion.create(
|
9 |
+
engine="gpt-3.5-turbo",
|
10 |
+
messages=[
|
11 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
12 |
+
{"role": "user", "{topic}"},
|
13 |
+
]
|
|
|
|
|
14 |
)
|
15 |
+
return response['content'][0]['text']
|
16 |
|
17 |
iface = gr.Interface(fn=generate_blog, inputs='text', outputs='text')
|
18 |
iface.launch()
|