Skip to main content
Delight users with a culinary copilot that suggests recipes, checks pantry items via tools, and returns structured shopping lists.

What you’ll build

  • A CrewAI agent with cooking-focused instructions.
  • Tools for pantry lookup and recipe generation.
  • Optional frontend action that displays a shopping list in your UI.

Prerequisites

  • CrewAI project (crew-ai.mdx)
  • Any ingredient/recipe API keys if you use a third-party source

Steps

1

Add pantry tool

Provide a tool to check ingredient availability (local DB or API). Return structured data for the agent.
2

Generate recipes

Let the LLM craft recipes using the pantry results. Keep responses concise with steps + ingredient list.
3

Optional shopping list action

Emit a UI action (see frontend actions guide) so your app can show a list or start a checkout flow.

Sample tools

src/crew_demo/tools/pantry.py
import json
from crewai.tools import tool

PANTRY = {"eggs": 6, "milk": 1, "flour": 500}  # grams or units


@tool("check_pantry")
def check_pantry(items: str) -> str:
    """Return which requested items exist in the pantry."""
    requested = [i.strip().lower() for i in items.split(",") if i.strip()]
    found = {item: PANTRY.get(item, 0) for item in requested}
    return json.dumps({"items": found})
src/crew_demo/tools/shopping_list.py
import json
from crewai.tools import tool


@tool("show_shopping_list")
def show_shopping_list(items: str) -> str:
    """Return a shopping list action for the frontend."""
    return json.dumps({
        "action": "show_shopping_list",
        "parameters": {"items": [i.strip() for i in items.split(",") if i.strip()]}
    })

Agent configuration

src/crew_demo/config/agents.yaml
chef:
  role: Culinary Assistant
  goal: Propose recipes users can cook with available ingredients
  backstory: >
    First check pantry items with check_pantry.
    Suggest a recipe with steps and a short shopping list if needed.
    If asked, trigger show_shopping_list with the missing items.

CometChat setup

Provider: CrewAI, Agent ID: chef, Deployment URL: /kickoff. Provide suggested prompts like “What can I make with eggs, milk, and flour?”.