abhishekt commited on
Commit
1006399
·
1 Parent(s): 0894461
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -20,18 +20,15 @@ def generate_article(topic):
20
  )
21
  article = response.choices[0].text
22
 
23
- # # Clean up the article text
24
- # article = re.sub('\n', ' ', article)
25
- # article = re.sub('\s+', ' ', article)
26
-
27
- # # Split the article into 5 sections
28
- # section_length = len(article) // 5
29
- # sections = [article[i:i+section_length] for i in range(0, len(article), section_length)]
30
-
31
- # # Combine the sections into a formatted blog post
32
- # blog_post = f"# {topic}\n\n"
33
- # for i in range(5):
34
- # blog_post += f"## Section {i+1}\n\n{sections[i]}\n\n"
35
 
36
  return article
37
 
 
20
  )
21
  article = response.choices[0].text
22
 
23
+ article = re.sub('\n', ' ', article)
24
+ article = re.sub('\s+', ' ', article)
25
+
26
+ section_length = len(article) // 5
27
+ sections = [article[i:i+section_length] for i in range(0, len(article), section_length)]
28
+
29
+ blog_post = f"# {topic}\n\n"
30
+ for i in range(5):
31
+ blog_post += f"## Section {i+1}\n\n{sections[i]}\n\n"
 
 
 
32
 
33
  return article
34