Files
2026-05-26 14:45:13 +00:00

44 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ShoppingList AI Assistant
This repository contains a minimal example of a hierarchical LangChain agent that can estimate prices for products in a city. The toplevel agent uses the ``get_price`` tool, which internally creates a shortlived subagent 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_price`` tool used by the main agent.
- **requirements.txt** Python dependencies (no pinned versions, only ``>=``).
- **README.md** this documentation.
## Installation
```bash
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
```bash
python main.py
```
You should see three blocks of output, each showing the assistants messages and the tool calls that were made.
## How it works
1. **Subagent** The ``get_price`` tool creates a lightweight subagent with a focused system prompt to generate a single markdown table row containing product name, price (rub.) and store.
2. **Main agent** Uses the ``get_price`` tool to estimate prices for each product in the users list.
3. **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.0`
- `langgraph>=0.2.0`
- `langchain-core>=0.3.0`
- `python-dotenv>=1.0.0`
All versions are specified with ``>=`` to avoid pinning to potentially nonexistent releases.