2026-05-26 14:45:04 +00:00
2026-05-26 14:44:53 +00:00
2026-05-26 14:45:04 +00:00
2026-05-26 13:49:02 +00:00
2026-05-26 14:44:43 +00:00

Simple Hierarchical AI ShoppingList Agent

What it does

This repository contains a minimal example of a hierarchical LangChain agent that helps you plan a shopping list. The main agent:

  1. Accepts a naturallanguage request with a list of products and a city.
  2. Calls an internal tool get_price(product, city) which itself creates a tiny subagent to generate realistic price tables for the requested product in the specified city.
  3. Aggregates the prices and prints a final summary.

The example demonstrates:

  • Connecting to a local LLM via LM Studio (OpenAIcompatible API).
  • Using @tool to expose a function that internally runs another agent.
  • Running the main agent with create_agent and printing all intermediate tool calls.

File structure

File Purpose
requirements.txt Pinning LangChain, langchainopenai and dotenv dependencies
main.py Full implementation of the hierarchical agent and demo usage
README.md This documentation

Installation

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt

Make sure LM Studio is running on http://localhost:1234/v1 (or set LM_BASE_URL and LM_MODEL).

Running the demo

python main.py

The script will:

  • Run the main agent with a hardcoded prompt.
  • Print each tool call (get_price) and its output.
  • Show aggregated price tables and total cost.

Feel free to modify user_prompt in main.py or pass input from stdin for interactive use.

S
Description
No description provided
Readme 35 KiB
Languages
Python 100%