Leospencer1 commited on
Commit
b6013d5
Β·
verified Β·
1 Parent(s): 075d3d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -14
app.py CHANGED
@@ -371,8 +371,34 @@ class WeeklyBudgetRecipeGenerator:
371
 
372
  def get_variation_context(self, meal_type, keep_titles=None):
373
  recent_for_type = [title for title in self.recipe_history[-20:] if meal_type.lower() in title.lower()]
374
- # Pick a RANDOM cuisine for more variety
375
- current_cuisine = random.choice(self.cuisine_rotation)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  exclusions = []
377
  if keep_titles:
378
  exclusions.extend(keep_titles)
@@ -438,11 +464,11 @@ class WeeklyBudgetRecipeGenerator:
438
  "- Basmati rice {1} 2/kg OR Pasta {1} 0.90/500g (as base)\n"
439
  "- Common UK veg: Carrots, peppers, mushrooms (seasonal)\n\n").format(num_to_generate, currency)
440
 
441
- # ADD EXCLUSIONS to prompt for more variety
442
  exclusions_text = ""
443
  if exclusions:
444
  exclusions_text = "\n\nDO NOT GENERATE THESE (already used recently):\n"
445
- for exc in exclusions[-10:]: # Show last 10
446
  exclusions_text += "- {0}\n".format(exc)
447
  exclusions_text += "\nMake sure ALL {0} recipes are COMPLETELY DIFFERENT from the above!\n".format(num_to_generate)
448
 
@@ -493,22 +519,42 @@ class WeeklyBudgetRecipeGenerator:
493
  prompt += "⚠️ CRITICAL: Generate RECIPE NAMES (dishes to cook), NOT ingredient lists!\n"
494
  prompt += "⚠️ WRONG: 'Beef Mince', 'Chicken Breast', 'Tinned Tomatoes' ❌\n"
495
  prompt += "⚠️ RIGHT: 'Shepherd's Pie', 'Chicken Curry', 'Pasta Bake' βœ…\n\n"
496
- prompt += "- Make names DESCRIPTIVE and APPETIZING (not boring!)\n"
497
- prompt += "- Use mouth-watering adjectives: Creamy, Crispy, Golden, Spicy, Herb-Crusted, Tender\n"
498
- prompt += "- Make people EXCITED to cook it!\n"
499
- prompt += "- BAD: 'Fish Pie', 'Chicken Dinner' ❌\n"
500
- prompt += "- GOOD: 'Golden Fish & Herb Pie', 'Crispy Garlic Chicken Feast' βœ…\n\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  prompt += "Format: DISH NAME | Short enticing description (5-8 words)\n\n"
502
  prompt += "Examples of GREAT UK-friendly DISH names (NOT ingredients!):\n"
 
 
 
 
 
 
 
503
  prompt += "Creamy Coconut Chicken Curry | Rich, warming, British-Indian classic\n"
504
  prompt += "Crispy Garlic Roasted Chicken | Juicy chicken with golden skin\n"
505
  prompt += "Mediterranean Tomato Pasta Bake | Cheesy, comforting, family favourite\n"
506
  prompt += "Spicy Bean Chilli with Rice | Quick, hearty, crowd-pleaser\n"
507
- prompt += "Golden Fish & Herb Pie | Flaky, hearty, proper comfort food\n"
508
- prompt += "Shepherd's Pie with a Twist | Classic British, budget-friendly\n"
509
- prompt += "Tender Beef & Veggie Stew | Slow-cooked, melt-in-mouth goodness\n\n"
510
- prompt += "⚠️ IMPORTANT: Return ONLY {0} complete DISH NAMES (like 'Shepherd's Pie'), NOT ingredients (like 'Beef Mince')!\n".format(num_to_generate)
511
- prompt += "Now generate {0} APPETIZING DISH names with descriptions:".format(num_to_generate)
512
 
513
  response = self.model.generate_content(prompt)
514
  titles_text = response.text.strip()
@@ -559,6 +605,16 @@ class WeeklyBudgetRecipeGenerator:
559
  if clean_title.lower() in plain_ingredients:
560
  continue
561
 
 
 
 
 
 
 
 
 
 
 
562
  # Skip if the title itself is too long (recipe names should be reasonable length)
563
  if len(clean_title) > 60:
564
  continue
 
371
 
372
  def get_variation_context(self, meal_type, keep_titles=None):
373
  recent_for_type = [title for title in self.recipe_history[-20:] if meal_type.lower() in title.lower()]
374
+
375
+ # WEIGHTED CUISINE SELECTION - UK FOCUSED!
376
+ # British gets 40% chance, UK-popular cuisines get higher weight
377
+ cuisine_weights = {
378
+ "British": 40, # 40% chance - fish & chips, roasts, pies, etc.
379
+ "Indian": 15, # UK's favourite takeaway!
380
+ "Italian": 12, # Very popular in UK
381
+ "Chinese": 8,
382
+ "Mediterranean": 8,
383
+ "Thai": 5,
384
+ "Mexican": 4,
385
+ "Greek": 3,
386
+ "French": 2,
387
+ "Spanish": 2,
388
+ "Middle Eastern": 1,
389
+ "Japanese": 0.5,
390
+ "Caribbean": 0.3,
391
+ "Korean": 0.1,
392
+ "Vietnamese": 0.1
393
+ }
394
+
395
+ # Create weighted list
396
+ weighted_cuisines = []
397
+ for cuisine, weight in cuisine_weights.items():
398
+ weighted_cuisines.extend([cuisine] * int(weight))
399
+
400
+ current_cuisine = random.choice(weighted_cuisines)
401
+
402
  exclusions = []
403
  if keep_titles:
404
  exclusions.extend(keep_titles)
 
464
  "- Basmati rice {1} 2/kg OR Pasta {1} 0.90/500g (as base)\n"
465
  "- Common UK veg: Carrots, peppers, mushrooms (seasonal)\n\n").format(num_to_generate, currency)
466
 
467
+ # ADD EXCLUSIONS to prompt for more variety (but not too many!)
468
  exclusions_text = ""
469
  if exclusions:
470
  exclusions_text = "\n\nDO NOT GENERATE THESE (already used recently):\n"
471
+ for exc in exclusions[-5:]: # Show only last 5 to avoid overwhelming
472
  exclusions_text += "- {0}\n".format(exc)
473
  exclusions_text += "\nMake sure ALL {0} recipes are COMPLETELY DIFFERENT from the above!\n".format(num_to_generate)
474
 
 
519
  prompt += "⚠️ CRITICAL: Generate RECIPE NAMES (dishes to cook), NOT ingredient lists!\n"
520
  prompt += "⚠️ WRONG: 'Beef Mince', 'Chicken Breast', 'Tinned Tomatoes' ❌\n"
521
  prompt += "⚠️ RIGHT: 'Shepherd's Pie', 'Chicken Curry', 'Pasta Bake' βœ…\n\n"
522
+
523
+ prompt += "🚫 FORBIDDEN BORING NAMES (NEVER use these!):\n"
524
+ prompt += "❌ 'Stir Fry' (too generic!)\n"
525
+ prompt += "❌ 'Pasta Bake' (boring!)\n"
526
+ prompt += "❌ 'Chicken Dinner' (lazy!)\n"
527
+ prompt += "❌ 'Rice Bowl' (unexciting!)\n"
528
+ prompt += "❌ 'Curry' alone (needs detail!)\n\n"
529
+
530
+ prompt += "βœ… EVERY NAME MUST HAVE:\n"
531
+ prompt += "- At least ONE descriptive adjective (Creamy, Crispy, Golden, Spicy, Tender, Hearty)\n"
532
+ prompt += "- Specific ingredients or style mentioned\n"
533
+ prompt += "- Make people EXCITED to cook it!\n\n"
534
+
535
+ prompt += "EXAMPLES OF TRANSFORMATION:\n"
536
+ prompt += "❌ 'Stir Fry' β†’ βœ… 'Spicy Garlic Chicken Stir-Fry'\n"
537
+ prompt += "❌ 'Pasta Bake' β†’ βœ… 'Mediterranean Tomato & Herb Pasta Bake'\n"
538
+ prompt += "❌ 'Curry' β†’ βœ… 'Creamy Coconut Chicken Curry'\n"
539
+ prompt += "❌ 'Pie' β†’ βœ… 'Golden Fish & Herb Pie'\n\n"
540
+
541
  prompt += "Format: DISH NAME | Short enticing description (5-8 words)\n\n"
542
  prompt += "Examples of GREAT UK-friendly DISH names (NOT ingredients!):\n"
543
+ prompt += "πŸ‡¬πŸ‡§ BRITISH CLASSICS:\n"
544
+ prompt += "Classic Shepherd's Pie | Traditional British comfort\n"
545
+ prompt += "Golden Fish & Herb Pie | Flaky, hearty, proper comfort food\n"
546
+ prompt += "Tender Beef & Veggie Stew | Slow-cooked, melt-in-mouth goodness\n"
547
+ prompt += "Crispy Jacket Potato Feast | Loaded, filling, budget-friendly\n"
548
+ prompt += "Hearty Sausage & Bean Casserole | Warming British favourite\n\n"
549
+ prompt += "🌍 UK-POPULAR INTERNATIONAL:\n"
550
  prompt += "Creamy Coconut Chicken Curry | Rich, warming, British-Indian classic\n"
551
  prompt += "Crispy Garlic Roasted Chicken | Juicy chicken with golden skin\n"
552
  prompt += "Mediterranean Tomato Pasta Bake | Cheesy, comforting, family favourite\n"
553
  prompt += "Spicy Bean Chilli with Rice | Quick, hearty, crowd-pleaser\n"
554
+ prompt += "Sticky Honey Garlic Chicken | Sweet, savoury perfection\n\n"
555
+ prompt += "⚠️ IMPORTANT: Return ONLY {0} complete APPETIZING DISH NAMES with descriptive words!\n".format(num_to_generate)
556
+ prompt += "NO boring generic names like 'Stir Fry' or 'Pasta Bake' alone!\n"
557
+ prompt += "Now generate {0} EXCITING, DESCRIPTIVE DISH names with descriptions:".format(num_to_generate)
 
558
 
559
  response = self.model.generate_content(prompt)
560
  titles_text = response.text.strip()
 
605
  if clean_title.lower() in plain_ingredients:
606
  continue
607
 
608
+ # REJECT BORING GENERIC TITLES
609
+ boring_titles = ['stir fry', 'stir-fry', 'pasta bake', 'rice bowl', 'curry',
610
+ 'chicken dinner', 'beef dinner', 'fish dinner', 'soup', 'salad',
611
+ 'noodles', 'rice', 'pasta', 'casserole']
612
+ # If the title is EXACTLY a boring word (or just adds 'the'), reject it
613
+ title_lower = clean_title.lower().replace('the ', '')
614
+ if title_lower in boring_titles:
615
+ print(f"Rejected boring title: {clean_title}")
616
+ continue
617
+
618
  # Skip if the title itself is too long (recipe names should be reasonable length)
619
  if len(clean_title) > 60:
620
  continue