Recipe engine: dietary constraints, glycemic limiter, and nutrition panel #8
Labels
No labels
backlog
beta-feedback
bug
duplicate
enhancement
help wanted
invalid
needs-design
needs-triage
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Circuit-Forge/kiwi#8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Feature Request
Dietary constraint filters should apply at all 4 creativity levels, not just LLM levels.
Proposed design
Add
dietary_constraints: list[str]toRecipeRequest. Map each constraint to:Level 1/2 (deterministic corpus)
Pre-filter recipes via SQL exclusion lists:
low_sugar/diabetic_friendly→ exclude recipes whereingredient_namescontains: sugar, brown sugar, honey, corn syrup, maple syrup, molasses, condensed milk, etc. AND/OR include recipes withkeywordscontainingdiabetic,low-sugar,sugar-freevegetarian→ exclude: chicken, beef, pork, bacon, fish, shrimp, etc.vegan→ vegetarian exclusions + dairy/egg exclusionsgluten_free→ exclude: flour, wheat, bread crumbs, pasta (unless gluten-free keyword)dairy_free→ exclude: milk, cream, cheese, butter, yogurtlow_sodium→ exclude high-sodium ingredients; prefer recipes without added saltnut_free→ exclude: almonds, walnuts, peanuts, cashews, pecans, etc.Level 3/4 (LLM)
Append to the existing
constraintsblock already passed to the LLM prompt.Trigger
User suggestion: diabetic user asked for low-sugar recipe options (2026-04-01).
Notes
dietary_profilestable in the DB (per-user saved profiles) — already gated as Paid tier featureingredient_profiles.categoryfor smarter filtering than string matchingAddendum: sugar substitute swaps
Instead of (or in addition to) hard-excluding recipes with sugar, the engine should suggest diabetic-friendly substitutes as
swap_candidateswhendiabetic_friendlyorlow_sugaris active.Substitute map (starting point)
Integration points
swap_candidateson matched recipes (sameSwapCandidatemodel already used for substitution_pairs)substitution_pairstable: seed these as a curated dietary-constraint-tagged subset so they appear in level 2 automaticallyUX note
Recipes should not be excluded purely because they contain sugar — instead surface them with the swap annotation so users can still cook familiar dishes adapted to their needs.
Recipe engine: dietary constraints filter (all levels)to Recipe engine: dietary constraints, glycemic limiter, and nutrition panelUser feedback — expanded to full nutrition panel
This is no longer just a diabetic filter. It is a nutrition panel feature that serves two clear audiences: health/diabetic users who need to limit specific macros, and fitness users who track macros precisely.
Revised spec
Data layer
Current state:
recipestable:calories,fat_g,protein_g— present on ~1,200 of 3.1M recipes (food.com corpus). No sugar, carbs, or sodium.ingredient_profilestable: hasfat_pct,protein_pct,starch_pct,sodium_mg_per_100g— no sugar field.ingredient_profiles.usda_fdc_id— can be used to backfill sugar + full nutrition.Pipeline additions needed (new migration + pipeline stage):
sugar_g_per_100g,carbs_g_per_100gtoingredient_profiles(backfill from USDA FDC API)sugar_g,carbs_g,sodium_mg,fiber_gtorecipes(estimate = Σ ingredient × quantity × per_100g ÷ 100)nutrition_estimated: bool) — show~prefix in UIRecipe request
Filter applied at level 1/2 via SQL
WHERE sugar_g <= ?(NULL rows pass through — no data = not excluded). Injected as hard constraints at level 3/4 LLM prompt.Recipe response — nutrition panel
UI
~prefix on estimated values; tooltip: "Estimated from ingredient profiles — not lab-verified"Audiences
Notes
Closing — dietary constraints (vegan/vegetarian/gluten-free/dairy-free/etc.), allergy list, and per-serving nutrition panel (kcal, fat, protein, carbs, fiber, sugar, sodium) are all wired. Nutrition filters (max_calories, max_sugar_g, max_carbs_g, max_sodium_mg) implemented in NutritionFilters schema. Texture profiles backfilled from macro data for 378K ingredient_profiles rows.