Skip to content

Daniyal117/langgraph-cooking-agent

Repository files navigation

AI Cooking Assistant (LangGraph + Streamlit)

Generate structured recipes from natural language using a multi-agent LangGraph pipeline and a Streamlit UI.

Features

  • Multi-agent pipeline: intent extraction, planning, ingredient optimization, steps, validation, confidence scoring.
  • Streamlit UI for interactive use.
  • CLI entrypoint for quick testing.
  • YouTube transcript-based validation (optional, via yt-dlp + faster-whisper).

Setup

  1. Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Configure environment variables:
touch .env

Then add this line inside .env:

OPENROUTER_API_KEY="your_openrouter_key_here"

Run

Streamlit UI:

streamlit run streamlit_app.py

CLI:

python main.py

Docker

Build image:

docker build -t cooking-assistant .

Run container:

docker run --rm -p 8501:8501 --env-file .env cooking-assistant

Optional (CLI in container):

docker run --rm --env-file .env cooking-assistant python main.py

Architecture (LangGraph)

This project uses a LangGraph StateGraph with a shared state object that flows through specialized nodes.

State

Defined in state.py as CookingState. It is a Python dict that represents the current workflow data:

  • Input: user_query
  • Understanding: intent, constraints
  • Planning: recipe_plan, optimized_ingredients, steps
  • Validation and output: validation, final_recipe
  • Meta: confidence, safety_flags, retries

Nodes

Defined in graph.py via graph.add_node(...). Each node reads state and returns an updated state:

  • intent_extractor -> parse intent + constraints
  • recipe_planner -> high-level plan
  • ingredient_optimizer -> adapt ingredients
  • step_generator -> generate steps
  • recipe_validator -> validate and finalize
  • confidence_scorer -> compute confidence score

Edges / Execution Order

The current graph is linear:

intent_extractor
  -> recipe_planner
  -> ingredient_optimizer
  -> step_generator
  -> recipe_validator
  -> confidence_scorer
  -> END

Graph definition lives in graph.py:

  • Nodes: graph.add_node(...)
  • Edges: graph.add_edge("from", "to")
  • Entry point: graph.set_entry_point("intent_extractor")

Notes / Limitations

  • The graph is currently sequential (no branching, retries, or feedback loops).
  • YouTube validation depends on network access and can be slow or fail if YouTube changes its HTML.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors