Pooja P commited on
Commit
d2e9f68
·
1 Parent(s): 138f215

used transformer instead of openai

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -32,7 +32,18 @@ import gradio as gr
32
 
33
  generator = pipeline("text-generation", model="EleutherAI/gpt-neo-125M")
34
 
 
 
 
 
 
 
 
 
35
  def generate_blog(topic):
 
 
 
36
  prompt = f"""
37
  Write a detailed and engaging blog post about "{topic}".
38
  Include an introduction, 2–3 subheadings with paragraphs, and a conclusion.
 
32
 
33
  generator = pipeline("text-generation", model="EleutherAI/gpt-neo-125M")
34
 
35
+ def clean_topic(topic):
36
+ topic = topic.lower()
37
+ if "write a blog on" in topic:
38
+ topic = topic.replace("write a blog on", "").strip()
39
+ elif "write a blog about" in topic:
40
+ topic = topic.replace("write a blog about", "").strip()
41
+ return topic.capitalize()
42
+
43
  def generate_blog(topic):
44
+ topic = clean_topic(topic)
45
+ if not topic:
46
+ return "Please provide a topic."
47
  prompt = f"""
48
  Write a detailed and engaging blog post about "{topic}".
49
  Include an introduction, 2–3 subheadings with paragraphs, and a conclusion.