Spaces:
Sleeping
Sleeping
Pooja P
commited on
Commit
·
c77b300
1
Parent(s):
89751b6
Pin openai to 0.28 for backward compatibility
Browse files- app.py +5 -11
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,18 +1,12 @@
|
|
1 |
-
|
2 |
-
import openai
|
3 |
-
import os
|
4 |
|
5 |
-
|
6 |
|
7 |
-
def generate_blog(
|
8 |
-
response =
|
9 |
model="gpt-3.5-turbo",
|
10 |
messages=[
|
11 |
-
{
|
12 |
-
{ "role": "user", "content": f"Write a blog on: {topic}" }
|
13 |
]
|
14 |
)
|
15 |
return response.choices[0].message.content
|
16 |
-
|
17 |
-
iface = gr.Interface(fn=generate_blog, inputs="text", outputs="text", title="Blog Generator AI")
|
18 |
-
iface.launch()
|
|
|
1 |
+
from openai import OpenAI
|
|
|
|
|
2 |
|
3 |
+
client = OpenAI()
|
4 |
|
5 |
+
def generate_blog(prompt):
|
6 |
+
response = client.chat.completions.create(
|
7 |
model="gpt-3.5-turbo",
|
8 |
messages=[
|
9 |
+
{"role": "user", "content": prompt}
|
|
|
10 |
]
|
11 |
)
|
12 |
return response.choices[0].message.content
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
openai
|
2 |
gradio
|
|
|
1 |
+
openai>=1.0.0
|
2 |
gradio
|