DrishtiSharma commited on
Commit
7692c8e
Β·
verified Β·
1 Parent(s): 114fe90

Update post_generator.py

Browse files
Files changed (1) hide show
  1. post_generator.py +175 -53
post_generator.py CHANGED
@@ -13,79 +13,201 @@ def get_length_str(length):
13
 
14
 
15
  def generate_post(length, language, tag, selected_tone=None):
 
 
 
 
16
  prompt = get_prompt(length, language, tag)
17
  response = llm.invoke(prompt)
18
  post_content = response.content
19
 
20
- # Add closing statements dynamically based on tone and language
 
 
 
 
21
  closing_lines = {
22
  "Motivational": {
23
- "English": [
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
- "Hinglish": [
30
- "Dhire dhire aage badho aur safalta pao! πŸ’ͺ",
31
- "Sapne bade rakho, unhe pura karo. 🌟",
32
- "Chhoti chhoti koshis se bade lakshya hasil hote hain! πŸš€",
33
- "Apne boundaries todho, aap kar sakte ho! πŸ”₯"
34
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  },
36
  "Professional": {
37
- "English": [
38
- "Looking forward to hearing your thoughts! πŸ‘”",
39
- "Let’s collaborate and make an impact together. 🌐",
40
- "Feel free to share your perspective below. πŸ“’",
41
- "Insights and feedback are always welcome. πŸ’‘"
42
- ],
43
- "Hinglish": [
44
- "Aapke vichar sunne ka intezaar hai! πŸ‘”",
45
- "Chaliye milkar kuch asar karte hain. 🌐",
46
- "Neeche apne vichar zaroor share karein. πŸ“’",
47
- "Aapka feedback hamare liye mahatvapurn hai. πŸ’‘"
48
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  },
50
  "Informal": {
51
- "English": [
52
- "What do you think? Let's chat in the comments! πŸ˜„",
53
- "Drop your thoughts below, would love to hear from you! πŸ—¨οΈ",
54
- "Let’s keep the conversation rolling. Share your views! πŸš€",
55
- "Got something to add? Don’t hold back! 😎"
56
- ],
57
- "Hinglish": [
58
- "Kya sochte ho? Comments mein baat karte hain! πŸ˜„",
59
- "Apne vichar neeche likho, sunne ke liye excited hoon! πŸ—¨οΈ",
60
- "Charcha ko jaari rakhein, apne vichar share karein! πŸš€",
61
- "Kuch add karna hai? Sharmana mat, batao! 😎"
62
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  },
64
  "Neutral": {
65
- "English": [
66
- "Thank you for reading. Your feedback is valued! πŸ™Œ",
67
- "Let’s connect and share ideas. 🌟",
68
- "Looking forward to engaging with you in the comments. πŸ’¬",
69
- "Your thoughts are always appreciated. 😊"
70
- ],
71
- "Hinglish": [
72
- "Padhne ke liye dhanyavaad. Aapka feedback mahatvapurn hai! πŸ™Œ",
73
- "Chaliye judein aur naye ideas share karein. 🌟",
74
- "Aapke vichar comments mein padhne ka intezaar hai. πŸ’¬",
75
- "Aapke sujhav hamesha sarankrit hote hain. 😊"
76
- ]
 
 
 
 
77
  }
78
  }
79
 
 
80
  if selected_tone and selected_tone in closing_lines:
81
- if language == "Hinglish" and "Hinglish" in closing_lines[selected_tone]:
82
- closing_line = closing_lines[selected_tone]["Hinglish"]
 
83
  else:
84
- closing_line = closing_lines[selected_tone]["English"]
85
 
86
  # Randomly select a closing line
87
  import random
88
- post_content += f"\n\n{random.choice(closing_line)}"
89
 
90
  return post_content
91
 
 
13
 
14
 
15
  def generate_post(length, language, tag, selected_tone=None):
16
+ """
17
+ Generate a LinkedIn post based on the given length, language, topic (tag), and tone.
18
+ """
19
+ # Prepare the prompt for the LLM
20
  prompt = get_prompt(length, language, tag)
21
  response = llm.invoke(prompt)
22
  post_content = response.content
23
 
24
+ # Fetch all available topics dynamically from FewShotPosts
25
+ fs = FewShotPosts()
26
+ all_topics = [topic.lower() for topic in fs.get_tags()]
27
+
28
+ # Closing lines structure
29
  closing_lines = {
30
  "Motivational": {
31
+ "English": {
32
+ "default": [
33
+ "Stay inspired and keep moving forward! πŸ’ͺ",
34
+ "Your journey to greatness begins today. 🌟",
35
+ "Remember, small steps lead to big achievements. πŸš€",
36
+ "Keep pushing your boundaries. You’ve got this! πŸ”₯"
37
+ ],
38
+ "dating": [
39
+ "Love yourself first; the rest will follow! πŸ’–",
40
+ "Every journey begins with a spark. Keep believing! ✨",
41
+ "Trust the process, and love will find its way. πŸ’•",
42
+ "Stay true to yourself, and the right person will connect. 🌸"
43
+ ],
44
+ "mental health": [
45
+ "Your mental health matters. Take care of yourself! πŸ’š",
46
+ "Small steps lead to great mental wellness. 🌿",
47
+ "Prioritize self-care; it’s your greatest investment. 🌼",
48
+ "Remember, it’s okay to seek help when needed. 🌟"
49
+ ],
50
+ "job search": [
51
+ "Your dream job is closer than you think. Keep going! πŸš€",
52
+ "Stay focused and determined; success is near. 🌟",
53
+ "Every application is a step toward your goal. ✨",
54
+ "Believe in your skills; the right opportunity awaits! πŸ’Ό"
55
+ ],
56
+ "technology": [
57
+ "Innovation starts with curiosity. Explore! πŸ’‘",
58
+ "Stay updated and keep learning in this ever-changing field. πŸ“±",
59
+ "Technology drives the future. Be part of it! πŸš€",
60
+ "Every breakthrough starts with an idea. What’s yours? 🌟"
61
+ ],
62
+ "wellness": [
63
+ "Health is wealth. Invest in yourself! πŸ’ͺ",
64
+ "Take time to nurture your body and soul. 🌸",
65
+ "Wellness is a journey, not a destination. 🌿",
66
+ "Small habits lead to a healthier, happier you. 🌼"
67
+ ]
68
+ },
69
+ "Hinglish": {
70
+ "default": [
71
+ "Dhire dhire aage badho aur safalta pao! πŸ’ͺ",
72
+ "Sapne bade rakho, unhe pura karo. 🌟",
73
+ "Chhoti chhoti koshis se bade lakshya hasil hote hain! πŸš€",
74
+ "Apne boundaries todho, aap kar sakte ho! πŸ”₯"
75
+ ],
76
+ "dating": [
77
+ "Khud se pyaar karo, baaki sab aasan hoga! πŸ’–",
78
+ "Har safar ek chhoti chamak se shuru hoti hai! ✨",
79
+ "Apne upar bharosa rakho, pyaar apna rasta dhund lega. πŸ’•",
80
+ "Apne asli roop mein raho, sahi insaan connect karega. 🌸"
81
+ ],
82
+ "mental health": [
83
+ "Aapki mental health mahatvapurn hai. Apna dhyan rakhein! πŸ’š",
84
+ "Chhoti chhoti koshis se acchi sehat milti hai. 🌿",
85
+ "Self-care ko prioritize karein; yeh aapka sabse bada asset hai. 🌼",
86
+ "Yaad rakhein, zarurat padne par madad lena bilkul sahi hai. 🌟"
87
+ ],
88
+ "job search": [
89
+ "Aapka sapno ka naukri aapke kareeb hai. Lage raho! πŸš€",
90
+ "Focus banaye rakhein; safalta paas hai. 🌟",
91
+ "Har application aapke goal ki taraf ek kadam hai. ✨",
92
+ "Apni skills par bharosa rakhein; sahi opportunity intezaar kar rahi hai! πŸ’Ό"
93
+ ],
94
+ "technology": [
95
+ "Innovation curiosity se shuru hoti hai. Khojiye! πŸ’‘",
96
+ "Stay updated, ye field hamesha badal rahi hai. πŸ“±",
97
+ "Technology future ko chalati hai. Hissa baniye! πŸš€",
98
+ "Har breakthrough ek idea se shuru hota hai. Aapka kya hai? 🌟"
99
+ ],
100
+ "wellness": [
101
+ "Health hi wealth hai. Khud par invest karein! πŸ’ͺ",
102
+ "Apne body aur soul ko nurture karne ka samay nikalien. 🌸",
103
+ "Wellness ek journey hai, destination nahi. 🌿",
104
+ "Chhoti aadatein ek healthy aur happy aap banati hain. 🌼"
105
+ ]
106
+ }
107
  },
108
  "Professional": {
109
+ "English": {
110
+ "default": [
111
+ "Looking forward to hearing your thoughts! πŸ‘”",
112
+ "Let’s collaborate and make an impact together. 🌐",
113
+ "Feel free to share your perspective below. πŸ“’",
114
+ "Insights and feedback are always welcome. πŸ’‘"
115
+ ],
116
+ "job search": [
117
+ "Networking is key to success. Let’s connect! πŸ‘”",
118
+ "Stay prepared and open to opportunities. 🌐",
119
+ "Professional growth starts with the right connections. πŸ“ˆ",
120
+ "Every step counts in your career journey. Keep moving! πŸ’Ό"
121
+ ],
122
+ "technology": [
123
+ "Technology thrives on collaboration. Let’s innovate together! πŸ’»",
124
+ "Stay curious and keep challenging the status quo. 🌐",
125
+ "Your insights can drive the next big breakthrough. Share below! πŸ’‘",
126
+ "Adaptation and growth go hand in hand in tech. Let’s excel! πŸš€"
127
+ ]
128
+ },
129
+ "Hinglish": {
130
+ "default": [
131
+ "Aapke vichar sunne ka intezaar hai! πŸ‘”",
132
+ "Chaliye milkar kuch asar karte hain. 🌐",
133
+ "Neeche apne vichar zaroor share karein. πŸ“’",
134
+ "Aapka feedback hamare liye mahatvapurn hai. πŸ’‘"
135
+ ],
136
+ "job search": [
137
+ "Networking safalta ki kunji hai. Chaliye judte hain! πŸ‘”",
138
+ "Tayyar rahiye aur naye opportunities ke liye khule rahiye. 🌐",
139
+ "Professional growth sahi connections se shuru hoti hai. πŸ“ˆ",
140
+ "Aapke career journey mein har kadam mahatvapurn hai. Lage raho! πŸ’Ό"
141
+ ],
142
+ "technology": [
143
+ "Technology collaboration se phalti phoolti hai. Milkar innovate karein! πŸ’»",
144
+ "Curiosity banaye rakhein aur naye challenges ko accept karein. 🌐",
145
+ "Aapke insights agla bada breakthrough laa sakte hain. Neeche share karein! πŸ’‘",
146
+ "Tech mein adaptation aur growth saath saath chalte hain. Chaliye excellence achieve karein! πŸš€"
147
+ ]
148
+ }
149
  },
150
  "Informal": {
151
+ "English": {
152
+ "default": [
153
+ "What do you think? Let's chat in the comments! πŸ˜„",
154
+ "Drop your thoughts below, would love to hear from you! πŸ—¨οΈ",
155
+ "Let’s keep the conversation rolling. Share your views! πŸš€",
156
+ "Got something to add? Don’t hold back! 😎"
157
+ ],
158
+ "dating": [
159
+ "What’s your idea of a perfect date? Let’s talk! 😍",
160
+ "Got a dating tip? Share it below! πŸ‘«",
161
+ "Dating stories? Share your fun experiences! ❀️",
162
+ "Let’s chat about love and connections! πŸ’•"
163
+ ]
164
+ },
165
+ "Hinglish": {
166
+ "default": [
167
+ "Kya sochte ho? Comments mein baat karte hain! πŸ˜„",
168
+ "Apne vichar neeche likho, sunne ke liye excited hoon! πŸ—¨οΈ",
169
+ "Charcha ko jaari rakhein, apne vichar share karein! πŸš€",
170
+ "Kuch add karna hai? Sharmana mat, batao! 😎"
171
+ ],
172
+ "dating": [
173
+ "Aapke liye perfect date kya hai? Bataiye! 😍",
174
+ "Koi dating tip hai? Share karein! πŸ‘«",
175
+ "Dating stories? Apne mazedar anubhav share karein! ❀️",
176
+ "Chaliye pyaar aur connection ke baare mein baat karein! πŸ’•"
177
+ ]
178
+ }
179
  },
180
  "Neutral": {
181
+ "English": {
182
+ "default": [
183
+ "Thank you for reading. Your feedback is valued! πŸ™Œ",
184
+ "Let’s connect and share ideas. 🌟",
185
+ "Looking forward to engaging with you in the comments. πŸ’¬",
186
+ "Your thoughts are always appreciated. 😊"
187
+ ]
188
+ },
189
+ "Hinglish": {
190
+ "default": [
191
+ "Padhne ke liye dhanyavaad. Aapka feedback mahatvapurn hai! πŸ™Œ",
192
+ "Chaliye judein aur naye ideas share karein. 🌟",
193
+ "Aapke vichar comments mein padhne ka intezaar hai. πŸ’¬",
194
+ "Aapke sujhav hamesha sarankrit hote hain. 😊"
195
+ ]
196
+ }
197
  }
198
  }
199
 
200
+ # Determine the appropriate closing lines
201
  if selected_tone and selected_tone in closing_lines:
202
+ tone_lines = closing_lines[selected_tone][language]
203
+ if tag.lower() in all_topics and tag.lower() in tone_lines:
204
+ topic_closing = tone_lines[tag.lower()]
205
  else:
206
+ topic_closing = tone_lines["default"]
207
 
208
  # Randomly select a closing line
209
  import random
210
+ post_content += f"\n\n{random.choice(topic_closing)}"
211
 
212
  return post_content
213