Spaces:
Sleeping
Sleeping
Upload agent.py with huggingface_hub
Browse files
agent.py
CHANGED
|
@@ -151,18 +151,30 @@ def parse_servings(text: str, default: int = 2) -> int:
|
|
| 151 |
|
| 152 |
|
| 153 |
def dish_kind(dish: str, core: str) -> str:
|
| 154 |
-
"""Classify the dish so the kitchen math fits it (a salad gets no simmer).
|
|
|
|
|
|
|
|
|
|
| 155 |
t = (dish or "").lower()
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
| 158 |
return "beverage"
|
| 159 |
-
if
|
| 160 |
-
|
| 161 |
-
"guacamole", "dip", "tartare", "carpaccio")):
|
| 162 |
return "raw"
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
return "simmered"
|
| 167 |
return "generic"
|
| 168 |
|
|
@@ -182,6 +194,17 @@ def kitchen_math_script(core: str, servings: int, allow_salt: bool, dish: str =
|
|
| 182 |
print(f"grounds: {{grounds_g}} g (1:{{ratio}} ratio)")
|
| 183 |
print(f"bloom: 30 s with ~{{round(grounds_g*2)}} g water, then pour the rest")
|
| 184 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
if kind == "raw":
|
| 186 |
salt = ('print(f"salt: {round(produce_g*0.006)} g (light, 0.6%)")'
|
| 187 |
if allow_salt else 'print("salt: skipped (constraint)")')
|
|
@@ -462,10 +485,14 @@ dish, the actual contents of their kitchen (messy free text), and any dietary
|
|
| 462 |
constraints. Your job is to turn that into a STAGED seasoning plan, grounded in
|
| 463 |
the Epicure flavour-science tools — never invent pairings.
|
| 464 |
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
|
| 470 |
You have these Epicure tools; call them to ground your choices:
|
| 471 |
{tools}
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
def dish_kind(dish: str, core: str) -> str:
|
| 154 |
+
"""Classify the dish so the kitchen math fits it (a salad gets no simmer).
|
| 155 |
+
|
| 156 |
+
Whole-word matching throughout, so short keywords don't match inside other
|
| 157 |
+
words ('tea' in 'steak', 'raw' in 'strawberry', 'tart' in 'tartare')."""
|
| 158 |
t = (dish or "").lower()
|
| 159 |
+
|
| 160 |
+
def has(*words):
|
| 161 |
+
return re.search(r"\b(" + "|".join(words) + r")\b", t) is not None
|
| 162 |
+
|
| 163 |
+
if core == "coffee" or has("coffee", "espresso", "latte", "tea", "brew", "matcha"):
|
| 164 |
return "beverage"
|
| 165 |
+
if has("salad", "slaw", "raw", "ceviche", "smoothie", "juice", "salsa",
|
| 166 |
+
"guacamole", "dip", "tartare", "carpaccio"):
|
|
|
|
| 167 |
return "raw"
|
| 168 |
+
# No bare 'sweet' — it would mis-flag 'sweet potato'. The \w*cakes? pattern
|
| 169 |
+
# catches cupcake/shortcake/cheesecake; the rest are whole words.
|
| 170 |
+
if (has("tart", "pie", "cookie", "biscuit", "brownie", "muffin", "scone",
|
| 171 |
+
"pastry", "crumble", "cobbler", "pudding", "custard", "dessert",
|
| 172 |
+
"mousse", "fudge", "parfait", "jam", "compote", "sorbet", "gelato")
|
| 173 |
+
or re.search(r"\b\w*cakes?\b", t) or "ice cream" in t):
|
| 174 |
+
return "sweet"
|
| 175 |
+
if core in ("lentil", "chickpea", "bean", "rice", "pasta") or has(
|
| 176 |
+
"soup", "stew", "curry", "dal", "dahl", "daal", "braise", "simmer",
|
| 177 |
+
"rice", "pasta", "risotto", "porridge", "congee", "chili", "chilli", "broth"):
|
| 178 |
return "simmered"
|
| 179 |
return "generic"
|
| 180 |
|
|
|
|
| 194 |
print(f"grounds: {{grounds_g}} g (1:{{ratio}} ratio)")
|
| 195 |
print(f"bloom: 30 s with ~{{round(grounds_g*2)}} g water, then pour the rest")
|
| 196 |
"""
|
| 197 |
+
if kind == "sweet":
|
| 198 |
+
return f"""
|
| 199 |
+
servings = {servings}
|
| 200 |
+
filling_g = servings * 120 # ~120 g fruit/nut filling per serving
|
| 201 |
+
sweetener_g = servings * 25 # ~25 g sugar/honey/syrup per serving
|
| 202 |
+
print(f"makes: {{servings}} servings")
|
| 203 |
+
print(f"fruit/nut filling: ~{{filling_g}} g total")
|
| 204 |
+
print(f"sweetener: ~{{sweetener_g}} g total, to taste")
|
| 205 |
+
print("salt: just a pinch, to lift the sweetness")
|
| 206 |
+
print("if baked: ~180C / 350F until set")
|
| 207 |
+
"""
|
| 208 |
if kind == "raw":
|
| 209 |
salt = ('print(f"salt: {round(produce_g*0.006)} g (light, 0.6%)")'
|
| 210 |
if allow_salt else 'print("salt: skipped (constraint)")')
|
|
|
|
| 485 |
constraints. Your job is to turn that into a STAGED seasoning plan, grounded in
|
| 486 |
the Epicure flavour-science tools — never invent pairings.
|
| 487 |
|
| 488 |
+
Sequence the additions sensibly for THIS dish. Treat the stage labels as a
|
| 489 |
+
generic order — robust/early elements first, aromatics next, the main body, then
|
| 490 |
+
delicate finishing touches (acids, fresh herbs, garnishes). Describe each step
|
| 491 |
+
TRUTHFULLY for the actual ingredient: never call something a "whole spice" or
|
| 492 |
+
"aromatic" if it isn't (a nut is not a spice; lemon is not an allium). Do NOT
|
| 493 |
+
assume savoury stovetop cooking — adapt your wording when the dish is a salad,
|
| 494 |
+
a drink, or a dessert/baked good. Only recommend things the cook actually has
|
| 495 |
+
(or a substitute you justify with the tools). Respect every constraint.
|
| 496 |
|
| 497 |
You have these Epicure tools; call them to ground your choices:
|
| 498 |
{tools}
|