DrishtiSharma
commited on
Update post_generator.py
Browse files- post_generator.py +38 -2
post_generator.py
CHANGED
@@ -13,10 +13,46 @@ def get_length_str(length):
|
|
13 |
return "11 to 15 lines"
|
14 |
|
15 |
|
16 |
-
def generate_post(length, language, tag):
|
17 |
prompt = get_prompt(length, language, tag)
|
18 |
response = llm.invoke(prompt)
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
|
22 |
def get_prompt(length, language, tag):
|
|
|
13 |
return "11 to 15 lines"
|
14 |
|
15 |
|
16 |
+
def generate_post(length, language, tag, selected_tone=None):
|
17 |
prompt = get_prompt(length, language, tag)
|
18 |
response = llm.invoke(prompt)
|
19 |
+
post_content = response.content
|
20 |
+
|
21 |
+
# Add closing statements dynamically based on tone
|
22 |
+
closing_lines = {
|
23 |
+
"Motivational": [
|
24 |
+
"Stay inspired and keep moving forward! πͺ",
|
25 |
+
"Your journey to greatness begins today. π",
|
26 |
+
"Remember, small steps lead to big achievements. π",
|
27 |
+
"Keep pushing your boundaries. Youβve got this! π₯"
|
28 |
+
],
|
29 |
+
"Professional": [
|
30 |
+
"Looking forward to hearing your thoughts! π",
|
31 |
+
"Letβs collaborate and make an impact together. π",
|
32 |
+
"Feel free to share your perspective below. π’",
|
33 |
+
"Insights and feedback are always welcome. π‘"
|
34 |
+
],
|
35 |
+
"Informal": [
|
36 |
+
"What do you think? Let's chat in the comments! π",
|
37 |
+
"Drop your thoughts below, would love to hear from you! π¨οΈ",
|
38 |
+
"Letβs keep the conversation rolling. Share your views! π",
|
39 |
+
"Got something to add? Donβt hold back! π"
|
40 |
+
],
|
41 |
+
"Neutral": [
|
42 |
+
"Thank you for reading. Your feedback is valued! π",
|
43 |
+
"Letβs connect and share ideas. π",
|
44 |
+
"Looking forward to engaging with you in the comments. π¬",
|
45 |
+
"Your thoughts are always appreciated. π"
|
46 |
+
]
|
47 |
+
}
|
48 |
+
|
49 |
+
if selected_tone and selected_tone in closing_lines:
|
50 |
+
# Randomly select a closing line from the appropriate tone category
|
51 |
+
import random
|
52 |
+
post_content += f"\n\n{random.choice(closing_lines[selected_tone])}"
|
53 |
+
|
54 |
+
return post_content
|
55 |
+
|
56 |
|
57 |
|
58 |
def get_prompt(length, language, tag):
|