ServerIntelligenceAgents
Nutrition Agent
Nutrition Agent calculating macro targets and scoring recipe nutritional adherence.
Nutrition Agent
The Nutrition Agent calculates daily caloric and macronutrient targets and scores candidate recipes based on their nutritional balance.
Implementation: nutrition.py
1. Targets Calculation
The agent defines the user's daily macronutrient targets:
- Predefined Targets: Uses the
macro_targetscontext object directly if it has been specified by the user. - Calculated Targets: If not specified, the agent performs calculations using BMR and TDEE formulas:
- BMR: Computes BMR based on body weight, height, age, and gender using the Mifflin-St Jeor equation.
- TDEE: Multiplies BMR by the multiplier for the user's activity level (sedentary, light, moderate, active, very active).
- Macro Split: Adjusts TDEE calories based on fitness goals (e.g. fat loss deficit: -500 kcal; muscle gain surplus: +300 kcal) and determines macro targets using standard ratios:
- Muscle Gain: 30% Protein, 45% Carbs, 25% Fat.
- Fat Loss: 35% Protein, 35% Carbs, 30% Fat.
- Maintenance: 25% Protein, 50% Carbs, 25% Fat.
2. Recipe Adherence Scoring
The agent evaluates how well each candidate recipe matches the calculated macro splits:
- Loads full food item specifications for each recipe from the database.
- Sums the total macros (calories, protein, carbs, fats) for the recipe using
calculate_recipe_nutrition. - Scores recipe adherence against the daily macro targets using
score_plan_adherence. - Sorts the list of scored recipes in descending order of their adherence score.