feat: solution for 'Практическое задание: AI-агент на LangChain'

This commit is contained in:
2026-05-28 12:55:03 +03:00
commit d06929ba6e
5 changed files with 180 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
# Shopping List AI Agent
This project demonstrates a simple hierarchical AI agent built with LangChain that helps plan a shopping list, fetches prices for each item using a subagent, and calculates the total cost.
## Prerequisites
- Python 3.10+
- A local LLM server (e.g., LM Studio) running at `http://localhost:1234/v1`.
The server must expose an OpenAIcompatible API.
## Installation
bash
# Clone the repository
git clone https://github.com/your-username/shopping-list-agent.git
cd shopping-list-agent
# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows use `venv\\Scripts\\activate`
# Install dependencies
pip install -r requirements.txt
## Running the Agent
bash
python src/main.py
The script will ask the agent to plan a shopping list for the following request:
Помоги составить список покупок: молоко, хлеб, яблоки. Я нахожусь в Казани.
The agent will:
1. Parse the list of products and the city.
2. For each product, invoke the `get_price` tool, which internally creates a subagent that generates a realistic price table.
3. Sum the prices and output the final total.
All intermediate tool calls and the final answer are printed to the console.
## Customization
- **Model**: Change the `model` parameter in `src/main.py` to match the model name exposed by your LM Studio instance.
- **Temperature**: Adjust the `temperature` argument to control the randomness of the responses.
## License
MIT License