main
Shopping‑List AI Assistant
This repository contains a minimal example of a hierarchical LangChain agent that can estimate prices for products in a city. The top‑level agent uses the get_price tool, which internally creates a short‑lived sub‑agent to generate a markdown table row with the price.
Project structure
- main.py – entry point; demonstrates three example calls and prints the full message chain.
- agent.py – defines the
get_pricetool used by the main agent. - requirements.txt – Python dependencies (no pinned versions, only
>=). - README.md – this documentation.
Installation
pip install -r requirements.txt
# Ensure LM Studio is running at http://localhost:1234/v1 or set the env vars below:
export LOCAL_LLM_MODEL=gpt-3.5-turbo
export LOCAL_LLM_BASE_URL=http://localhost:1234/v1
export LOCAL_LLM_API_KEY=fake
Running the examples
python main.py
You should see three blocks of output, each showing the assistant’s messages and the tool calls that were made.
How it works
- Sub‑agent – The
get_pricetool creates a lightweight sub‑agent with a focused system prompt to generate a single markdown table row containing product name, price (rub.) and store. - Main agent – Uses the
get_pricetool to estimate prices for each product in the user’s list. - Output – The assistant prints all intermediate messages (tool calls) followed by the final answer summarizing the shopping list and total cost.
Dependencies
langchain-openai>=0.3.0langgraph>=0.2.0langchain-core>=0.3.0python-dotenv>=1.0.0
All versions are specified with >= to avoid pinning to potentially non‑existent releases.
Description
Languages
Python
100%