Spaces:
Sleeping
Sleeping
Pooja P
commited on
Commit
·
812dd54
1
Parent(s):
a9a4045
used transformer instead of openai
Browse files
app.py
CHANGED
|
@@ -1,18 +1,6 @@
|
|
| 1 |
-
|
| 2 |
-
from openai import OpenAI
|
| 3 |
|
| 4 |
-
|
| 5 |
|
| 6 |
-
def generate_blog(
|
| 7 |
-
|
| 8 |
-
model="gpt-3.5-turbo",
|
| 9 |
-
messages=[
|
| 10 |
-
{"role": "user", "content": prompt}
|
| 11 |
-
]
|
| 12 |
-
)
|
| 13 |
-
return response.choices[0].message.content
|
| 14 |
-
|
| 15 |
-
iface = gr.Interface(fn=generate_blog, inputs="text", outputs="text")
|
| 16 |
-
|
| 17 |
-
# ✅ REQUIRED to run on Hugging Face
|
| 18 |
-
iface.launch()
|
|
|
|
| 1 |
+
from transformers import pipeline
|
|
|
|
| 2 |
|
| 3 |
+
generator = pipeline("text-generation", model="gpt2")
|
| 4 |
|
| 5 |
+
def generate_blog(topic):
|
| 6 |
+
return generator(f"Write a blog on: {topic}", max_length=200)[0]["generated_text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|