V8b
Browse files
app.py
CHANGED
@@ -20,18 +20,15 @@ def generate_article(topic):
|
|
20 |
)
|
21 |
article = response.choices[0].text
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
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 |
|