Skip to content

Instantly share code, notes, and snippets.

@duarteocarmo
Created May 2, 2025 08:32
Show Gist options
  • Save duarteocarmo/83487a0da408c2470c9b23b257e66931 to your computer and use it in GitHub Desktop.
Save duarteocarmo/83487a0da408c2470c9b23b257e66931 to your computer and use it in GitHub Desktop.
[2025-04-30T19:46:45.175648]
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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
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 ## ]]`.
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 ## ]]
100 g of peanut butter
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": "Peanut butter (100g)", "quantity": 1.0, "calories": 588, "carbs": 20.0, "fat": 50.0, "protein": 25.0, "fiber": 6.0, "food_groups": ["meat and alternatives"]}]
[[ ## completed ## ]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment