Ozgur Unlu commited on
Commit
7c962de
1 Parent(s): d4b3687

added more templates for variety

Browse files
Files changed (1) hide show
  1. app.py +132 -30
app.py CHANGED
@@ -75,59 +75,161 @@ def generate_content(
75
  features = [f.strip() for f in key_features.split(',')]
76
  benefits = [b.strip() for b in unique_benefits.split(',')]
77
 
78
- # Create marketing message templates based on tone
79
  intro_phrases = {
80
  'professional': [
81
  f"Introducing {product_name}:",
82
  f"Discover {product_name}:",
83
  f"Meet {product_name}:",
 
 
 
 
84
  ],
85
  'casual': [
86
  f"Check out {product_name}!",
87
  f"Say hello to {product_name}!",
88
  f"Get ready for {product_name}!",
 
 
 
 
89
  ],
90
  'friendly': [
91
- f"You'll love {product_name}!",
92
- f"Experience {product_name}!",
93
- f"We're excited to present {product_name}!",
 
 
 
 
94
  ]
95
  }
96
-
97
- # Use professional tone as default if tone not found
98
- selected_tone = tone.lower() if tone.lower() in intro_phrases else 'professional'
99
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  import random
101
-
102
  def create_post():
103
- # Start with a random intro
104
- post = random.choice(intro_phrases[selected_tone])
105
-
106
- # Add main description
107
- post += f" {product_description}"
108
 
109
- # Add a key feature and benefit
110
- feature = random.choice(features)
111
- benefit = random.choice(benefits)
112
-
113
- if len(post) + len(feature) + len(benefit) + 10 < char_limit:
114
- post += f" Featuring {feature}."
115
- post += f" {benefit}."
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  # Add target audience if space allows
118
- if len(post) + len(target_audience) + 15 < char_limit:
119
- post += f" Perfect for {target_audience}."
120
-
121
  # Add call to action
122
  if platform == "Twitter":
123
  if len(post) + 30 < char_limit:
124
- post += " Learn more at our website!"
125
- else: # Instagram
126
- if len(post) + 20 < char_limit:
127
- post += f"\n\n#{product_name.replace(' ', '')}"
128
-
129
  return post.strip()
130
-
131
  try:
132
  # Generate multiple versions
133
  posts = [create_post() for _ in range(2)]
 
75
  features = [f.strip() for f in key_features.split(',')]
76
  benefits = [b.strip() for b in unique_benefits.split(',')]
77
 
78
+ # Expanded intro phrases for each tone
79
  intro_phrases = {
80
  'professional': [
81
  f"Introducing {product_name}:",
82
  f"Discover {product_name}:",
83
  f"Meet {product_name}:",
84
+ f"Presenting {product_name}:",
85
+ f"Announcing {product_name}:",
86
+ f"Experience {product_name}:",
87
+ f"Elevate your life with {product_name}:",
88
  ],
89
  'casual': [
90
  f"Check out {product_name}!",
91
  f"Say hello to {product_name}!",
92
  f"Get ready for {product_name}!",
93
+ f"You'll love {product_name}!",
94
+ f"Looking for something special? Try {product_name}!",
95
+ f"Meet your new favorite: {product_name}!",
96
+ f"Game-changer alert: {product_name} is here!",
97
  ],
98
  'friendly': [
99
+ f"We're excited to share {product_name} with you!",
100
+ f"You'll love what {product_name} can do!",
101
+ f"Let {product_name} transform your day!",
102
+ f"Ready to discover {product_name}?",
103
+ f"Here's why you'll love {product_name}:",
104
+ f"Make every day better with {product_name}!",
105
+ f"Transform your experience with {product_name}!",
106
  ]
107
  }
108
+
109
+ # Description connectors
110
+ description_connectors = [
111
+ f" - {product_description}",
112
+ f": {product_description}",
113
+ f"! {product_description}",
114
+ f", {product_description}",
115
+ f". {product_description}",
116
+ ]
117
+
118
+ # Feature introduction phrases
119
+ feature_intros = [
120
+ "Featuring",
121
+ "With",
122
+ "Including",
123
+ "Equipped with",
124
+ "Powered by",
125
+ "Designed with",
126
+ "Built with",
127
+ "Offering",
128
+ ]
129
+
130
+ # Benefit connectors
131
+ benefit_connectors = [
132
+ "Experience",
133
+ "Enjoy",
134
+ "Benefit from",
135
+ "Take advantage of",
136
+ "Discover",
137
+ "Appreciate",
138
+ "Make the most of",
139
+ ]
140
+
141
+ # Target audience phrases
142
+ audience_phrases = [
143
+ f"Perfect for {target_audience}",
144
+ f"Ideal for {target_audience}",
145
+ f"Designed for {target_audience}",
146
+ f"Made specially for {target_audience}",
147
+ f"Tailored for {target_audience}",
148
+ f"Created with {target_audience} in mind",
149
+ ]
150
+
151
+ # Call-to-action phrases
152
+ cta_phrases = {
153
+ 'Twitter': [
154
+ "Learn more today!",
155
+ "Discover more →",
156
+ "Get yours now!",
157
+ "Visit our website!",
158
+ "Join us today!",
159
+ "Transform your life today!",
160
+ "Start your journey!",
161
+ ],
162
+ 'Instagram': [
163
+ f"\n\n#{product_name.replace(' ', '')}",
164
+ f"\n\nLearn more - Link in bio! #{product_name.replace(' ', '')}",
165
+ f"\n\nDiscover more ↗️ #{product_name.replace(' ', '')}",
166
+ f"\n\nTap link to learn more! #{product_name.replace(' ', '')}",
167
+ ]
168
+ }
169
+
170
  import random
171
+
172
  def create_post():
173
+ # Select tone
174
+ selected_tone = tone.lower() if tone.lower() in intro_phrases else 'professional'
 
 
 
175
 
176
+ # Random structure selection (1-4)
177
+ structure = random.randint(1, 4)
 
 
 
 
 
178
 
179
+ if structure == 1:
180
+ # Standard structure
181
+ post = random.choice(intro_phrases[selected_tone])
182
+ post += random.choice(description_connectors)
183
+ feature = random.choice(features)
184
+ benefit = random.choice(benefits)
185
+
186
+ if len(post) + len(feature) + len(benefit) + 20 < char_limit:
187
+ post += f" {random.choice(feature_intros)} {feature}."
188
+ post += f" {random.choice(benefit_connectors)} {benefit}."
189
+
190
+ elif structure == 2:
191
+ # Benefit-first structure
192
+ benefit = random.choice(benefits)
193
+ post = f"Ready to {benefit.lower()}? "
194
+ post += random.choice(intro_phrases[selected_tone])
195
+ post += random.choice(description_connectors)
196
+
197
+ if len(post) + 30 < char_limit:
198
+ feature = random.choice(features)
199
+ post += f" {random.choice(feature_intros)} {feature}."
200
+
201
+ elif structure == 3:
202
+ # Question-based structure
203
+ post = f"Looking for {product_description.lower()}? "
204
+ post += random.choice(intro_phrases[selected_tone]).replace(':', '!')
205
+ feature = random.choice(features)
206
+ benefit = random.choice(benefits)
207
+
208
+ if len(post) + len(feature) + len(benefit) + 20 < char_limit:
209
+ post += f" {random.choice(feature_intros)} {feature}."
210
+ post += f" {benefit}."
211
+
212
+ else:
213
+ # Feature-focused structure
214
+ feature = random.choice(features)
215
+ post = f"From {feature} to {random.choice(benefits).lower()}, "
216
+ post += f"{product_name} has it all! "
217
+ post += product_description
218
+
219
  # Add target audience if space allows
220
+ if len(post) + 50 < char_limit:
221
+ post += f" {random.choice(audience_phrases)}."
222
+
223
  # Add call to action
224
  if platform == "Twitter":
225
  if len(post) + 30 < char_limit:
226
+ post += f" {random.choice(cta_phrases['Twitter'])}"
227
+ else:
228
+ if len(post) + 50 < char_limit:
229
+ post += random.choice(cta_phrases['Instagram'])
230
+
231
  return post.strip()
232
+
233
  try:
234
  # Generate multiple versions
235
  posts = [create_post() for _ in range(2)]