Skip to content

Instantly share code, notes, and snippets.

@duarteocarmo
Created December 23, 2025 12:12
Show Gist options
  • Select an option

  • Save duarteocarmo/99df3327c918daa5b68c97572a3e0ee6 to your computer and use it in GitHub Desktop.

Select an option

Save duarteocarmo/99df3327c918daa5b68c97572a3e0ee6 to your computer and use it in GitHub Desktop.
[2025-12-23T12:09:54.626836]
System message:
Your input fields are:
1. `food_description` (str): The description of the food item
Your output fields are:
1. `food_items` (list[FoodItem]): A list of food items with their nutritional information
All interactions will be structured in the following way, with the appropriate values filled in.
[[ ## food_description ## ]]
{food_description}
[[ ## food_items ## ]]
{food_items} # note: the value you produce must adhere to the JSON schema: {"type": "array", "$defs": {"FoodItem": {"type": "object", "description": "A food item.\n\nNotes:\n - The quantity is the amount of the food item in the user's description.\n - quantity multiplied by calories should result in a reasonable value!", "properties": {"calories": {"type": "number", "__dspy_field_type": "output", "desc": "Calories in kilocalories (kcal) for a single unit of the food item", "description": "Calories in kilocalories (kcal) for a single unit of the food item", "prefix": "Calories:", "title": "Calories"}, "carbs": {"type": "number", "__dspy_field_type": "output", "desc": "Carbohydrates in grams for a single unit of the food item", "description": "Carbohydrates in grams for a single unit of the food item", "prefix": "Carbs:", "title": "Carbs"}, "fat": {"type": "number", "__dspy_field_type": "output", "desc": "Fat in grams for a single unit of the food item", "description": "Fat in grams for a single unit of the food item", "prefix": "Fat:", "title": "Fat"}, "fiber": {"type": "number", "__dspy_field_type": "output", "desc": "Fiber in grams for a single unit of the food item", "description": "Fiber in grams for a single unit of the food item", "prefix": "Fiber:", "title": "Fiber"}, "food_groups": {"type": "array", "__dspy_field_type": "output", "desc": "The food groups to which the food item belongs", "description": "The food groups to which the food item belongs", "items": {"type": "string", "enum": ["dairy", "meat and alternatives", "grain", "fruit", "vegetable"]}, "prefix": "Food Groups:", "title": "Food Groups"}, "name": {"type": "string", "__dspy_field_type": "output", "desc": "The name of the food item", "description": "The name of the food item", "prefix": "Name:", "title": "Name"}, "protein": {"type": "number", "__dspy_field_type": "output", "desc": "Protein in grams for a single unit of the food item", "description": "Protein in grams for a single unit of the food item", "prefix": "Protein:", "title": "Protein"}, "quantity": {"type": "number", "__dspy_field_type": "output", "desc": "The quantity of the food item", "description": "The quantity of the food item", "prefix": "Quantity:", "title": "Quantity"}}, "required": ["name", "quantity", "calories", "carbs", "fat", "protein", "fiber"], "title": "FoodItem"}}, "items": {"$ref": "#/$defs/FoodItem"}}
[[ ## completed ## ]]
In adhering to this structure, your objective is:
Nutritional analysis
User message:
[[ ## food_description ## ]]
avocado toast
Assistant message:
[[ ## food_items ## ]]
[{"name": "Whole wheat toast", "quantity": 1.0, "calories": 80.0, "carbs": 14.0, "fat": 1.0, "protein": 3.0, "fiber": 2.0, "food_groups": ["grain"]}, {"name": "Avocado (half)", "quantity": 1.0, "calories": 160.0, "carbs": 8.5, "fat": 14.5, "protein": 2.0, "fiber": 6.7, "food_groups": ["fruit"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
2 toasts with cheese and butter – 2 pomodorini
Assistant message:
[[ ## food_items ## ]]
[{"name": "Toast (white bread)", "quantity": 2.0, "calories": 77.0, "carbs": 15.0, "fat": 1.0, "protein": 2.5, "fiber": 1.0, "food_groups": ["grain"]}, {"name": "Cheese slice", "quantity": 2.0, "calories": 75.0, "carbs": 0.5, "fat": 6.5, "protein": 4.5, "fiber": 0.0, "food_groups": ["dairy"]}, {"name": "Butter (toast)", "quantity": 2.0, "calories": 36.0, "carbs": 0.0, "fat": 4.0, "protein": 0.0, "fiber": 0.0, "food_groups": ["dairy"]}, {"name": "Cherry tomatoes", "quantity": 2.0, "calories": 3.0, "carbs": 0.7, "fat": 0.0, "protein": 0.1, "fiber": 0.2, "food_groups": ["vegetable"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
mezzo panino caprese
Assistant message:
[[ ## food_items ## ]]
[{"name": "White bread roll (½)", "quantity": 1.0, "calories": 120, "carbs": 23.0, "fat": 1.5, "protein": 4.0, "fiber": 1.0, "food_groups": ["grain"]}, {"name": "Fresh mozzarella (≈45 g)", "quantity": 1.0, "calories": 120, "carbs": 1.0, "fat": 9.0, "protein": 9.0, "fiber": 0.0, "food_groups": ["dairy"]}, {"name": "Tomato slices (≈30 g)", "quantity": 1.0, "calories": 5, "carbs": 1.1, "fat": 0.05, "protein": 0.2, "fiber": 0.3, "food_groups": ["vegetable"]}, {"name": "Olive oil (1 tsp)", "quantity": 1.0, "calories": 40, "carbs": 0.0, "fat": 4.5, "protein": 0.0, "fiber": 0.0, "food_groups": []}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
bacalhau com natas 509 g
Assistant message:
[[ ## food_items ## ]]
[{"name": "Bacalhau com natas (100g)", "quantity": 5.09, "calories": 180, "carbs": 12.0, "fat": 11.0, "protein": 10.0, "fiber": 1.0, "food_groups": ["meat and alternatives", "dairy", "vegetable"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
um palmier do Careca
Assistant message:
[[ ## food_items ## ]]
[{"name": "Palmier pastry from Careca", "quantity": 1.0, "calories": 220, "carbs": 18.0, "fat": 11.0, "protein": 2.0, "fiber": 0.5, "food_groups": ["grain"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
plate of pasta with olive oil and butter
Assistant message:
[[ ## food_items ## ]]
[{"name": "Pasta (cooked, plate)", "quantity": 1.0, "calories": 280, "carbs": 56.0, "fat": 2.0, "protein": 10.0, "fiber": 3.0, "food_groups": ["grain"]}, {"name": "Olive oil (1 tbsp)", "quantity": 1.0, "calories": 119, "carbs": 0.0, "fat": 13.5, "protein": 0.0, "fiber": 0.0, "food_groups": []}, {"name": "Butter (1 tbsp)", "quantity": 1.0, "calories": 102, "carbs": 0.1, "fat": 11.5, "protein": 0.1, "fiber": 0.0, "food_groups": ["dairy"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
pasta with pesto and tomatoes
Assistant message:
[[ ## food_items ## ]]
[{"name": "Pasta (cooked, serving)", "quantity": 1.0, "calories": 210, "carbs": 42.0, "fat": 1.5, "protein": 7.5, "fiber": 2.2, "food_groups": ["grain"]}, {"name": "Pesto sauce (30g)", "quantity": 1.0, "calories": 120, "carbs": 2.0, "fat": 12.0, "protein": 3.0, "fiber": 0.5, "food_groups": ["vegetable", "dairy"]}, {"name": "Tomatoes (chopped, 50g)", "quantity": 1.0, "calories": 9, "carbs": 2.0, "fat": 0.1, "protein": 0.5, "fiber": 0.6, "food_groups": ["vegetable"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
2 cookies
Assistant message:
[[ ## food_items ## ]]
[{"name": "Chocolate‑chip cookie (medium)", "quantity": 2.0, "calories": 80, "carbs": 10.0, "fat": 4.5, "protein": 1.0, "fiber": 0.5, "food_groups": ["grain"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
a bag of dried apple snacks
Assistant message:
[[ ## food_items ## ]]
[{"name": "Dried apple snacks (bag)", "quantity": 1.0, "calories": 140, "carbs": 38.0, "fat": 0.2, "protein": 0.5, "fiber": 4.0, "food_groups": ["fruit"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
500 g pasta with pesto and tomatoes
Assistant message:
[[ ## food_items ## ]]
[{"name": "Pasta (cooked) per 100g", "quantity": 5.0, "calories": 131, "carbs": 25.1, "fat": 1.1, "protein": 5.0, "fiber": 1.2, "food_groups": ["grain"]}, {"name": "Pesto sauce (60g)", "quantity": 1.0, "calories": 240, "carbs": 3.0, "fat": 24.0, "protein": 6.0, "fiber": 1.0, "food_groups": ["vegetable", "dairy"]}, {"name": "Tomatoes (100g)", "quantity": 1.0, "calories": 18, "carbs": 3.9, "fat": 0.2, "protein": 0.9, "fiber": 1.2, "food_groups": ["vegetable"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
apple
Assistant message:
[[ ## food_items ## ]]
[{"name": "Apple (medium)", "quantity": 1.0, "calories": 95, "carbs": 25.0, "fat": 0.3, "protein": 0.5, "fiber": 4.4, "food_groups": ["fruit"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
100 g of pasta
Assistant message:
[[ ## food_items ## ]]
[{"name": "Pasta (cooked) per 100g", "quantity": 1.0, "calories": 158, "carbs": 31.0, "fat": 1.0, "protein": 6.0, "fiber": 2.0, "food_groups": ["grain"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
small corn pastry
Assistant message:
[[ ## food_items ## ]]
[{"name": "Small corn pastry", "quantity": 1.0, "calories": 165, "carbs": 23.0, "fat": 7.0, "protein": 3.0, "fiber": 1.5, "food_groups": ["grain", "vegetable"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
2 tacos on homemade corn tortillas: one with arroz and barbacoa, one with arroz and fajita plus a little chicharrón
Assistant message:
[[ ## food_items ## ]]
[{"name": "Corn tortilla (homemade)", "quantity": 2.0, "calories": 60, "carbs": 12.0, "fat": 1.5, "protein": 1.5, "fiber": 1.0, "food_groups": ["grain"]}, {"name": "White rice (small serving)", "quantity": 1.0, "calories": 100, "carbs": 22.0, "fat": 0.3, "protein": 2.2, "fiber": 0.5, "food_groups": ["grain"]}, {"name": "Barbacoa beef (taco filling)", "quantity": 1.0, "calories": 120, "carbs": 1.0, "fat": 8.0, "protein": 10.0, "fiber": 0.0, "food_groups": ["meat and alternatives"]}, {"name": "Fajita meat (taco filling)", "quantity": 1.0, "calories": 110, "carbs": 2.0, "fat": 6.0, "protein": 11.0, "fiber": 0.0, "food_groups": ["meat and alternatives"]}, {"name": "Chicharrón (small)", "quantity": 1.0, "calories": 40, "carbs": 0.0, "fat": 4.0, "protein": 2.0, "fiber": 0.0, "food_groups": ["meat and alternatives"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
panino mortadella
Assistant message:
[[ ## food_items ## ]]
[{"name": "White bread roll", "quantity": 1.0, "calories": 250, "carbs": 48.0, "fat": 3.0, "protein": 9.0, "fiber": 2.0, "food_groups": ["grain"]}, {"name": "Mortadella (≈60 g)", "quantity": 1.0, "calories": 180, "carbs": 1.0, "fat": 16.0, "protein": 10.0, "fiber": 0.0, "food_groups": ["meat and alternatives"]}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
300 g of pasta with butter and olive oil
Assistant message:
[[ ## food_items ## ]]
[{"name": "Pasta (cooked) per 100g", "quantity": 3.0, "calories": 130, "carbs": 26.0, "fat": 0.5, "protein": 4.5, "fiber": 1.2, "food_groups": ["grain"]}, {"name": "Butter (1 tbsp)", "quantity": 1.0, "calories": 108, "carbs": 0.01, "fat": 12.2, "protein": 0.1, "fiber": 0.0, "food_groups": ["dairy"]}, {"name": "Olive oil (1 tbsp)", "quantity": 1.0, "calories": 120, "carbs": 0.0, "fat": 14.0, "protein": 0.0, "fiber": 0.0, "food_groups": []}]
[[ ## completed ## ]]
User message:
[[ ## food_description ## ]]
half a pao de deus from padaria portuguesa with cheese
Respond with the corresponding output fields, starting with the field `[[ ## food_items ## ]]` (must be formatted as a valid Python list[FoodItem]), and then ending with the marker for `[[ ## completed ## ]]`.
Response:
[[ ## food_items ## ]]
[{"name": "Pão de Deus (half)", "quantity": 1.0, "calories": 215.0, "carbs": 28.0, "fat": 9.0, "protein": 5.5, "fiber": 1.2, "food_groups": ["grain", "dairy"]}, {"name": "Cheese slice (Flamengo)", "quantity": 1.0, "calories": 90.0, "carbs": 0.5, "fat": 7.0, "protein": 6.5, "fiber": 0.0, "food_groups": ["dairy"]}]
[[ ## completed ## ]]
[2025-12-23T12:11:58.771659]
System message:
Your input fields are:
1. `food_description` (str): The description of the food item
Your output fields are:
1. `food_items` (list[FoodItem]): A list of food items with their nutritional information
All interactions will be structured in the following way, with the appropriate values filled in.
Inputs will have the following structure:
[[ ## food_description ## ]]
{food_description}
Outputs will be a JSON object with the following fields.
{
"food_items": "{food_items} # note: the value you produce must adhere to the JSON schema: {\"type\": \"array\", \"$defs\": {\"FoodItem\": {\"type\": \"object\", \"description\": \"A food item.\\n\\nNotes:\\n - The quantity is the amount of the food item in the user's description.\\n - quantity multiplied by calories should result in a reasonable value!\", \"properties\": {\"calories\": {\"type\": \"number\", \"__dspy_field_type\": \"output\", \"desc\": \"Calories in kilocalories (kcal) for a single unit of the food item\", \"description\": \"Calories in kilocalories (kcal) for a single unit of the food item\", \"prefix\": \"Calories:\", \"title\": \"Calories\"}, \"carbs\": {\"type\": \"number\", \"__dspy_field_type\": \"output\", \"desc\": \"Carbohydrates in grams for a single unit of the food item\", \"description\": \"Carbohydrates in grams for a single unit of the food item\", \"prefix\": \"Carbs:\", \"title\": \"Carbs\"}, \"fat\": {\"type\": \"number\", \"__dspy_field_type\": \"output\", \"desc\": \"Fat in grams for a single unit of the food item\", \"description\": \"Fat in grams for a single unit of the food item\", \"prefix\": \"Fat:\", \"title\": \"Fat\"}, \"fiber\": {\"type\": \"number\", \"__dspy_field_type\": \"output\", \"desc\": \"Fiber in grams for a single unit of the food item\", \"description\": \"Fiber in grams for a single unit of the food item\", \"prefix\": \"Fiber:\", \"title\": \"Fiber\"}, \"food_groups\": {\"type\": \"array\", \"__dspy_field_type\": \"output\", \"desc\": \"The food groups to which the food item belongs\", \"description\": \"The food groups to which the food item belongs\", \"items\": {\"type\": \"string\", \"enum\": [\"dairy\", \"meat and alternatives\", \"grain\", \"fruit\", \"vegetable\"]}, \"prefix\": \"Food Groups:\", \"title\": \"Food Groups\"}, \"name\": {\"type\": \"string\", \"__dspy_field_type\": \"output\", \"desc\": \"The name of the food item\", \"description\": \"The name of the food item\", \"prefix\": \"Name:\", \"title\": \"Name\"}, \"protein\": {\"type\": \"number\", \"__dspy_field_type\": \"output\", \"desc\": \"Protein in grams for a single unit of the food item\", \"description\": \"Protein in grams for a single unit of the food item\", \"prefix\": \"Protein:\", \"title\": \"Protein\"}, \"quantity\": {\"type\": \"number\", \"__dspy_field_type\": \"output\", \"desc\": \"The quantity of the food item\", \"description\": \"The quantity of the food item\", \"prefix\": \"Quantity:\", \"title\": \"Quantity\"}}, \"required\": [\"name\", \"quantity\", \"calories\", \"carbs\", \"fat\", \"protein\", \"fiber\"], \"title\": \"FoodItem\"}}, \"items\": {\"$ref\": \"#/$defs/FoodItem\"}}"
}
In adhering to this structure, your objective is:
You are performing a nutritional analysis from a short free-text food_description. Parse the described foods and amounts, estimate nutrition, and output a list of FoodItem objects.
Output format (strict):
- Return ONLY a single Python-style list literal of FoodItem objects, nothing else. Example:
[FoodItem(name='apple', quantity=1.0, calories=95.0, carbs=25.0, fat=0.3, protein=0.5, fiber=4.4, food_groups=['fruit'])]
- FoodItem fields:
- name: concise common name (include brand/place if specified; e.g., 'palmier do Careca').
- quantity: float = number of per-unit servings you are using for this item (see quantity rules).
- calories: float = kcal PER ONE UNIT of quantity.
- carbs, fat, protein, fiber: floats in grams PER ONE UNIT of quantity.
- food_groups: list of strings chosen from:
['fruit', 'vegetable', 'grain', 'dairy', 'meat and alternatives', 'legume', 'nut and seed', 'fat and oils', 'sweets and snacks', 'beverage'].
If unclear, use [].
Critical rule about quantity and per-unit nutrition:
- The evaluator totals calories as sum(quantity * calories). Therefore, calories/macros MUST be per ONE unit of quantity.
- If a specific portion or amount is given (e.g., “100 g yogurt”, “1 slice pizza”, “half sandwich”), compute the TOTAL for that described portion and set quantity=1.0 with calories/macros equal to that total for the portion.
- If a count of identical units is given (e.g., “2 eggs”, “15 almonds”, “2 little focaccia pieces”), you may set quantity to that count, BUT then calories/macros must be per single unit (not totals). Never mix totals with quantity>1.
- Do NOT set quantity equal to grams while also providing totals for that gram amount. Either:
- Convert to a single portion: quantity=1.0 and set totals for that gram amount; OR
- Use quantity in grams AND provide calories/macros per gram (generally avoid; prefer quantity=1.0 with totals).
- Fractions like “half/mezzo/meia/mezza”: treat as a single half-portion. Set quantity=1.0 and provide the totals for that half portion (avoid fractional quantities).
Interpretation and itemization rules:
- Parse the description to identify distinct foods and their amounts. When amounts are in grams, compute totals proportionally from per-100 g references and set quantity=1.0.
- Do not invent or add separate items unless clearly present. Toppings/modifiers (“with X,” “on a medium crust”) belong to the same item unless the text indicates a separate serving.
- For vague size descriptors (e.g., “little focaccia pieces”), choose a conservative per-piece size consistent with the descriptor.
- Keep names clear; use singular with quantity>1 for identical units, otherwise describe the whole portion with quantity=1.0.
- Language cues:
- “um/uma” (PT), “uno/una” (IT/ES) = 1 unit.
- “mezzo/mezza” (IT), “meio/meia” (PT) = half; treat as one half-portion with quantity=1.0.
- Keep brand/place indicators (e.g., “do/da/de [Brand]”) in the name.
Estimation guidance:
- Prefer realistic, conservative estimates when portions are unspecified to avoid overestimation, but do not undercount obvious mains or full bowls. Use per-100 g baselines and scale by grams if provided. Adjust macros so kcal ≈ 4*carbs + 4*protein + 9*fat (allow rounding).
- Packaging/serving cues:
- “a bag” of snacks: assume single-serve.
- Dried fruit bag: ≈35–43 g (≈140–170 kcal).
- “small coffee” ≈8–12 fl oz.
- “tablespoon” ≈15–20 g for jams/spreads; use 20 g for jam unless otherwise stated.
- Beverages: include as items (e.g., water, coffee, soda). Water is 0 kcal. For sugar-sweetened sodas, assume a standard can (12 fl oz/355 mL) when unspecified unless context indicates otherwise.
Category baselines (per 100 g unless noted). Use these when applicable; scale by grams if provided, or choose reasonable single-serving totals if not. Use higher-end realistic baselines for main staples/hearty bowls.
Core/common:
- Water: 0 kcal; macros 0; food_groups=['beverage'].
- Brewed coffee, black (small cup 8–12 fl oz): 2–5 kcal; carbs/fat/protein ~0 g; food_groups=['beverage'].
- Flavored coffee creamer, single-serve cup/pod (10–15 mL): ≈30–45 kcal; carbs ≈4–6 g; fat ≈1.5–2.5 g; protein ≈0 g; food_groups=['dairy'].
- Regular plain bagel (≈90–105 g): ≈270–300 kcal; carbs ≈53–58 g; fat ≈1–2 g; protein ≈9–11 g; fiber ≈2–3 g; food_groups=['grain'].
- Jam/jelly (per tablespoon ≈20 g): ≈50 kcal; carbs ≈13 g; fat 0 g; protein 0 g; fiber ≈0–0.5 g; food_groups=['fruit'].
- Grapes, red/green: ≈69 kcal/100 g; carbs ≈18 g; fat ≈0.2 g; protein ≈0.7 g; fiber ≈0.9 g; food_groups=['fruit'].
- Rice, cooked:
- White rice: ≈130 kcal/100 g; carbs ≈28 g; fat ≈0.3 g; protein ≈2.4 g; fiber ≈0.3 g; food_groups=['grain'].
- Glutinous (sticky) rice, steamed/plain: ≈130–150 kcal/100 g by default when unspecified (use higher end if a main staple).
- Fish and soups:
- Fish, white (cooked): ≈90–120 kcal/100 g; carbs 0 g; fat ≈2–5 g; protein ≈18–22 g; food_groups=['meat and alternatives'].
- Hearty fish broth soups (e.g., striped snakehead fish broth soup): ≈100–130 kcal/100 g unless clearly “light/clear.”
- Cheese pizza, general: ≈238 kcal/100 g; carbs ≈30 g; fat ≈9 g; protein ≈10 g; fiber ≈2 g; food_groups=['grain'].
- Stracciatella (fresh cheese): ≈300 kcal/100 g; carbs ≈2 g; fat ≈27 g; protein ≈12 g; fiber 0 g; food_groups=['dairy'].
- Confit grapes (small garnish): 30–60 kcal total per tablespoon or two; mostly carbs; fiber ≈0–1 g; food_groups=['fruit'].
- Focaccia, “little piece” (≈15–20 g each): ≈45–60 kcal per piece; carbs ≈8–12 g; fat ≈1–2 g; protein ≈1–2 g; fiber ≈0.3–0.6 g; food_groups=['grain'].
- Common seabream, cooked: ≈90 kcal/100 g; carbs 0 g; fat ≈2 g; protein ≈18 g; food_groups=['meat and alternatives'].
- Matabala, boiled: ≈30 kcal/100 g; carbs ≈7–9 g; fat ≈0.1 g; protein ≈0.5–1 g; fiber ≈1–2 g; food_groups=['vegetable'].
- Rice with vegetables, cooked mixed: ≈90 kcal/100 g; carbs ≈18–20 g; fat ≈0.8–1.2 g; protein ≈2–3 g; fiber ≈1 g; food_groups=['grain', 'vegetable'].
- Palmier pastry (elephant ear; 50–60 g typical single pastry total): ≈220–260 kcal (use 220 kcal if unspecified to be conservative); carbs ≈25–30 g; fat ≈12–15 g; protein ≈2–4 g; fiber ≈0.5–1.5 g; food_groups=['sweets and snacks'].
- Pasta with pesto and tomatoes (cooked mixed dish): ≈180–200 kcal/100 g; carbs ≈23–26 g; fat ≈7–10 g; protein ≈4–6 g; fiber ≈1.5–2.5 g; food_groups=['grain', 'vegetable', 'fat and oils'].
- Panino caprese (whole): ≈520–620 kcal; carbs ≈55–65 g; fat ≈22–30 g; protein ≈20–30 g; fiber ≈3–5 g; ['grain', 'dairy', 'vegetable'].
- “Mezzo/mezza” (half): treat as single half-portion with ≈260–320 kcal; set quantity=1.0.
Additional baselines and clarifications (derived from prior tasks/errors):
- Mixed stew with chicken, potatoes, vegetables: ≈85–95 kcal/100 g (use ≈90 kcal/100 g by default unless clearly creamy/rich). Per 100 g macros: carbs ≈8–10 g; fat ≈3–4 g; protein ≈5–7 g; fiber ≈1–2 g; food_groups=['meat and alternatives', 'vegetable'].
- Example: 300 g → ≈270 kcal total; set quantity=1.0 with totals for that portion.
- Takeout kebab sandwich on baguette (doner-style meat + bread + veg + sauces): typical whole sandwich total ≈550–650 kcal when unspecified; carbs ≈50–60 g; fat ≈22–30 g; protein ≈25–35 g; fiber ≈4–6 g; food_groups=['grain', 'meat and alternatives', 'vegetable'].
- Fries (takeout/fast-food):
- Per 100 g ≈300–320 kcal; carbs ≈40 g; fat ≈15–17 g; protein ≈3–4 g; fiber ≈3–4 g; food_groups=['vegetable'].
- When unspecified in a combo, assume a small/regular single-serve: ≈85–100 g (≈250–320 kcal).
- Soda (sugar-sweetened; e.g., mango soda): standard can (12 fl oz/355 mL) ≈140–160 kcal; carbs ≈35–41 g; fat 0 g; protein 0 g; fiber 0 g; food_groups=['beverage'].
- Do NOT tag sodas/soft drinks as 'fruit' or 'vegetable' even if fruit-flavored; use only ['beverage'].
- Toast with cheese and butter (per toast/slice): ≈170–200 kcal; carbs ≈16–20 g; fat ≈9–11 g; protein ≈6–8 g; fiber ≈1–2 g; food_groups=['grain', 'dairy'].
- For “2 toasts with cheese and butter,” you may set quantity=2.0 with per-toast nutrition.
Food group mapping guidance:
- dairy: milk, yogurt, cheeses (mozzarella, stracciatella), coffee creamer.
- grain: bread, bagel, rice, pizza crust, focaccia, pasta.
- meat and alternatives: fish (e.g., snakehead, seabream), chicken, eggs, wurst, kebab meat.
- fruit: fresh fruit, jams/jellies, dried fruit snacks (not sodas).
- sweets and snacks: sweet pastries (e.g., palmier), candies, chips.
- beverage: water, coffee/tea, sodas and soft drinks, juices.
- Include additional groups (vegetable, legume, nut and seed, fat and oils) when clearly applicable.
Handling explicit target calories:
- If the description includes an explicit/approximate total calorie target (e.g., “~250 cal”, “total of 700 cals”), ensure the sum over all items is within ±10% of that target. Adjust portion assumptions and per-item estimates accordingly, while staying realistic.
Quality checks before output:
- Verify totals make sense: sum(quantity * calories) should be sensible and (if a target was stated) within ±10% of the target.
- Ensure macros roughly align with calories (kcal ≈ 4*carbs + 4*protein + 9*fat).
- For gram-specified amounts: compute totals by (grams/100) * per-100 g baseline; set quantity=1.0.
- For counted items (pieces, slices): set quantity to the count; provide per-unit nutrition, not totals.
- For fractional portions (half/mezzo/etc.): set quantity=1.0 with totals for that fraction.
- When portions are unspecified for takeout combos or packaged snacks, assume modest, single-serve amounts (e.g., small fries, 12-oz soda, typical single sandwich) to avoid overestimation.
Implementation tips:
- Use higher-end realistic baselines for main staples and hearty bowls (e.g., sticky rice, pesto pasta, hearty soups).
- Treat separate add-ins (e.g., coffee creamer) as separate items.
- Keep names concise but include brand/place when given (e.g., 'palmier do Careca').
- Do not include any explanatory text—return only the list of FoodItem(...) objects.
User message:
[[ ## food_description ## ]]
half a pao de deus from padaria portuguesa with cheese
Respond with a JSON object in the following order of fields: `food_items` (must be formatted as a valid Python list[FoodItem]).
Response:
{
"food_items": [
{
"name": "half pao de deus with cheese from padaria portuguesa",
"quantity": 1.0,
"calories": 250.0,
"carbs": 25.0,
"fat": 12.0,
"protein": 10.0,
"fiber": 1.5,
"food_groups": [
"grain",
"dairy"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment