Ozgur Unlu commited on
Commit
531606c
β€’
1 Parent(s): 9fb1b7d

small changes

Browse files
Files changed (2) hide show
  1. app.py +70 -72
  2. requirements.txt +2 -1
app.py CHANGED
@@ -5,6 +5,8 @@ import nltk
5
  from datetime import datetime, timedelta
6
  import requests
7
  from bs4 import BeautifulSoup
 
 
8
 
9
  # Download required NLTK data
10
  try:
@@ -90,7 +92,6 @@ def generate_content(
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!",
@@ -102,7 +103,6 @@ def generate_content(
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
 
@@ -157,7 +157,6 @@ def generate_content(
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(' ', '')}",
@@ -268,8 +267,75 @@ def generate_content(
268
  'safety_score': '1.00'
269
  }]
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  def create_interface():
272
  print("Loading models...")
 
273
  generator_tokenizer, generator, sentiment_analyzer, content_checker = load_models()
274
  print("Models loaded successfully!")
275
 
@@ -287,74 +353,6 @@ def create_interface():
287
  def clear_form():
288
  return [""] * 7 # Returns empty strings for all 7 input fields
289
 
290
- import time
291
-
292
- def process_input_with_loading(
293
- product_name,
294
- product_description,
295
- target_audience,
296
- key_features,
297
- unique_benefits,
298
- platform,
299
- tone,
300
- progress=gr.Progress()
301
- ):
302
- # Initial loading message
303
- features_list = """⚑ While I generate your content, here's what I can do:
304
-
305
- πŸ“ Generate multiple unique marketing messages
306
- 🎯 Adapt content for different platforms
307
- πŸ” Ensure ethical content generation
308
- πŸ“Š Analyze sentiment and safety
309
- ✨ Create platform-specific formatting
310
-
311
- Processing your request..."""
312
-
313
- yield features_list + "\n\n⏳ Starting generation..."
314
- time.sleep(1)
315
-
316
- # Update message with steps
317
- steps = [
318
- "Loading language models...",
319
- "Analyzing product information...",
320
- "Generating content variations...",
321
- "Checking content safety...",
322
- "Finalizing output..."
323
- ]
324
-
325
- for i, step in enumerate(steps, 1):
326
- progress(i/len(steps))
327
- yield features_list + f"\n\n⏳ {step}"
328
- time.sleep(1)
329
-
330
- # Generate actual content
331
- try:
332
- results = generate_content(
333
- product_name,
334
- product_description,
335
- target_audience,
336
- key_features,
337
- unique_benefits,
338
- platform,
339
- tone,
340
- generator_tokenizer,
341
- generator,
342
- sentiment_analyzer,
343
- content_checker
344
- )
345
-
346
- output = "🎯 Generated Marketing Content:\n\n"
347
- for i, content in enumerate(results, 1):
348
- output += f"Version {i}:\n"
349
- output += f"πŸ“ Content: {content['text']}\n"
350
- output += f"😊 Sentiment: {content['sentiment']}\n"
351
- output += f"βœ… Safety Score: {content['safety_score']}\n"
352
- output += "-" * 50 + "\n"
353
-
354
- yield output
355
- except Exception as e:
356
- yield f"An error occurred: {str(e)}"
357
-
358
  # Create the interface with blocks for custom layout
359
  with gr.Blocks(theme=gr.themes.Default()) as demo:
360
  gr.Markdown("# Ethimar - AI Marketing Content Generator")
@@ -366,7 +364,7 @@ Processing your request..."""
366
  "Fill the form with sample data",
367
  variant="primary",
368
  size="sm",
369
- scale=0.2
370
  )
371
 
372
  # Main content area with two columns
 
5
  from datetime import datetime, timedelta
6
  import requests
7
  from bs4 import BeautifulSoup
8
+ import time
9
+ import emoji
10
 
11
  # Download required NLTK data
12
  try:
 
92
  f"Check out {product_name}!",
93
  f"Say hello to {product_name}!",
94
  f"Get ready for {product_name}!",
 
95
  f"Looking for something special? Try {product_name}!",
96
  f"Meet your new favorite: {product_name}!",
97
  f"Game-changer alert: {product_name} is here!",
 
103
  f"Ready to discover {product_name}?",
104
  f"Here's why you'll love {product_name}:",
105
  f"Make every day better with {product_name}!",
 
106
  ]
107
  }
108
 
 
157
  "Visit our website!",
158
  "Join us today!",
159
  "Transform your life today!",
 
160
  ],
161
  'Instagram': [
162
  f"\n\n#{product_name.replace(' ', '')}",
 
267
  'safety_score': '1.00'
268
  }]
269
 
270
+ def process_input_with_loading(
271
+ product_name,
272
+ product_description,
273
+ target_audience,
274
+ key_features,
275
+ unique_benefits,
276
+ platform,
277
+ tone,
278
+ progress=gr.Progress()
279
+ ):
280
+ # Initial loading message
281
+ features_list = """⚑ While I generate your content, here's what I can do:
282
+
283
+ πŸ“ Generate multiple unique marketing messages
284
+ 🎯 Adapt content for different platforms
285
+ πŸ” Ensure ethical content generation
286
+ πŸ“Š Analyze sentiment and safety
287
+ ✨ Create platform-specific formatting
288
+
289
+ Processing your request..."""
290
+
291
+ yield features_list + "\n\n⏳ Starting generation..."
292
+ time.sleep(1)
293
+
294
+ # Update message with steps
295
+ steps = [
296
+ "Loading language models...",
297
+ "Analyzing product information...",
298
+ "Generating content variations...",
299
+ "Checking content safety...",
300
+ "Finalizing output..."
301
+ ]
302
+
303
+ for i, step in enumerate(steps, 1):
304
+ progress(i/len(steps))
305
+ yield features_list + f"\n\n⏳ {step}"
306
+ time.sleep(1)
307
+
308
+ # Generate actual content
309
+ try:
310
+ results = generate_content(
311
+ product_name,
312
+ product_description,
313
+ target_audience,
314
+ key_features,
315
+ unique_benefits,
316
+ platform,
317
+ tone,
318
+ generator_tokenizer,
319
+ generator,
320
+ sentiment_analyzer,
321
+ content_checker
322
+ )
323
+
324
+ output = "🎯 Generated Marketing Content:\n\n"
325
+ for i, content in enumerate(results, 1):
326
+ output += f"Version {i}:\n"
327
+ output += f"πŸ“ Content: {content['text']}\n"
328
+ output += f"😊 Sentiment: {content['sentiment']}\n"
329
+ output += f"βœ… Safety Score: {content['safety_score']}\n"
330
+ output += "-" * 50 + "\n"
331
+
332
+ yield output
333
+ except Exception as e:
334
+ yield f"An error occurred: {str(e)}"
335
+
336
  def create_interface():
337
  print("Loading models...")
338
+ global generator_tokenizer, generator, sentiment_analyzer, content_checker
339
  generator_tokenizer, generator, sentiment_analyzer, content_checker = load_models()
340
  print("Models loaded successfully!")
341
 
 
353
  def clear_form():
354
  return [""] * 7 # Returns empty strings for all 7 input fields
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  # Create the interface with blocks for custom layout
357
  with gr.Blocks(theme=gr.themes.Default()) as demo:
358
  gr.Markdown("# Ethimar - AI Marketing Content Generator")
 
364
  "Fill the form with sample data",
365
  variant="primary",
366
  size="sm",
367
+ scale=1
368
  )
369
 
370
  # Main content area with two columns
requirements.txt CHANGED
@@ -4,4 +4,5 @@ transformers
4
  nltk
5
  requests
6
  beautifulsoup4
7
- lxml
 
 
4
  nltk
5
  requests
6
  beautifulsoup4
7
+ lxml
8
+ emoji==0.6.0