Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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[-
|
| 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 |
-
|
| 497 |
-
prompt += "
|
| 498 |
-
prompt += "
|
| 499 |
-
prompt += "
|
| 500 |
-
prompt += "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 += "
|
| 508 |
-
prompt += "
|
| 509 |
-
prompt += "
|
| 510 |
-
prompt += "
|
| 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
|