Skip to content

minasmz/NutriPlan-AI-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯— NutriPlan AI

An Intelligent Multi-Agent Nutrition Assistant Powered by Google ADK & Gemini

NutriPlan AI is a fully featured multi-agent system designed to generate safe, personalized daily meal plans, compute macronutrients, and retrieve real-world nutrition facts via search.
It demonstrates practical use of LLM‑powered agents, sequential workflows, custom tools, memory reasoning, observability, and automated evaluation.

I personally built this project because I often struggle with the everyday question:
β€œWhat should I eat today?”
NutriPlan AI answers that question with structure, safety, and intelligence.


πŸ“Œ Table of Contents


🧠 Project Overview

NutriPlan AI is an intelligent, multi-agent nutrition assistant that helps users:

βœ“ Generate a personalized 1‑day meal plan
βœ“ Calculate recommended macros based on calorie targets
βœ“ Retrieve nutrition facts using real Google Search
βœ“ Maintain lightweight memory during the conversation
βœ“ Enforce health safety guardrails for extreme calorie values
βœ“ Provide observability through logging and evaluation tooling

The system is built to be:

  • Modular β€” each agent handles one responsibility
  • Safe β€” strict calorie guardrails prevent harmful recommendations
  • Intuitive β€” detects greetings, help requests, farewells, nutrition queries, and plan requests
  • Extensible β€” additional tools or agents can be plugged in seamlessly

πŸ€– Demo

  • A suggested plan based on 1500 calories and no dietary restrictions 1500None

  • A suggested vegeterian plan based on 1800 calories 1500None

  • Google Search Response for Food Macro Query googlesearch


Installation

Clone the repository:

git clone https://github.com/minasmz/nutriplan-ai-agent.git
cd nutriplan-ai-agent

Create (optional) a virtual environment:

python3 -m venv venv
source venv/bin/activate

Install Google ADK with all extras:

pip install "google-adk[all]"

Running the Agent

Inside the project folder:

adk run nutri

This launches your full NutriPlan AI assistant.


Project Architecture

NutriPlan AI is built using a root router agent that delegates every user message to the appropriate sub-agent:

User β†’ Root Agent β†’ {Greeting, Help, Preprocess, Meal Planner, Nutrition Search, Farewell}

Architecture Diagram

High-Level Flow

  1. GreetingAgent β€” triggers on simple greetings
  2. HelpAgent β€” explains capabilities
  3. FarewellAgent β€” exits politely
  4. NutritionSearchAgent β€” answers nutrition fact questions
  5. NutritionFlowGroup (SequentialAgent)
    • NutritionPreprocessAgent collects:
      • daily_calories
      • dietary_preferences
    • NutritionistPlannerAgent generates macros + meal plan
  6. Router chooses EXACTLY ONE agent per turn

This ensures clarity, determinism, and removes ambiguity.


πŸ€– Multi-Agent Design

NutriPlan AI demonstrates three key ADK concepts:

βœ”οΈ LLM-Powered Agents

All agents run on Gemini 2.5 Flash, each with different instructions.

βœ”οΈ Sequential Agents

NutritionFlowGroup chains:

  1. Preprocessing
  2. Planning

Ensuring the meal plan is only produced when all inputs are known.

βœ”οΈ Custom Router Logic

The root agent uses explicit tool-selection rules to determine flow.


πŸ”§ Tooling

NutriPlan AI uses two categories of tools:

1. Custom Python Tool

A handcrafted macro calculator:

def calculate_macros(daily_calories: int) -> dict:
    # 30% protein, 40% carbs, 30% fats
    ...
    return {"protein_g": ..., "carbs_g": ..., "fats_g": ...}

Used by NutritionistPlannerAgent to create the Recommended Macros section.

2. Built-in ADK Tool: google_search

from google.adk.tools import google_search

Used by NutritionSearchAgent to answer questions like:

  • β€œHow many calories are in an avocado?”
  • β€œIs brown rice higher in fiber than white rice?”

googlesearch


🧡 Memory & Context Handling

Although ADK’s full session memory tools aren't used here,
NutritionPreprocessAgent reads the entire conversation history to detect:

  • previously stated calories
  • previously stated dietary preferences

This prevents repetitive questions and creates a lightweight memory layer.


πŸ”’ Safety Guardrails

The planner refuses to generate a meal plan if:

daily_calories < 1000 OR > 5000

The agent returns a medical safety warning instead.

This demonstrates safe LLM deployment practices.

guardrails


πŸ“Š Observability & Logging

The project uses:

βœ”οΈ Python Logging

logger.info("Calculating macros for daily_calories=%s", daily_calories)

βœ”οΈ ADK Automatic Logs

ADK automatically outputs:

  • Tool calls
  • Agent routing
  • LLM responses
  • Execution metadata

▢️ Live Log Monitoring

tail -F /path/to/agents_log/agent.latest.log

logInfo


πŸ§ͺ Evaluation

NutriPlan AI includes a custom eval set:

evals/nutriplan_basic_evalset.json

Run evaluation:

adk eval nutri evals/nutriplan_basic_evalset.json > evals/results.json

πŸ“‚ Evaluation History

ADK stores results under:

nutri/.adk/eval_history/

Metrics Included

  • tool_trajectory_avg_score
  • response_match_score

πŸ“ Project Structure

nutriplan-ai/
β”‚
β”œβ”€β”€ nutri/
β”‚   β”œβ”€β”€ agent.py
β”‚   └── __init__.py
β”‚
β”œβ”€β”€ evals/
β”‚   β”œβ”€β”€ nutriplan_basic_evalset.json
β”‚   └── results.json
β”‚
└── README.md

πŸ“Ž Requirements

  • Python 3.11+
  • google-adk (installed via pip)
  • Gemini API key configured as:
    • GOOGLE_API_KEY


πŸ“„ License

This project is released under the MIT License.
Feel free to fork, extend, remix, and build upon it.

This work was developed as part of the Kaggle Agents Intensive Capstone Project:
πŸ”— https://www.kaggle.com/competitions/agents-intensive-capstone-project/


If you use this project or build on it, I’d love to hear about it!
Happy learning! πŸŽ‰

About

A personalized AI agent that generates daily meal plans based on calorie goals and dietary preferences.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages