Files

54 lines
1.6 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.
# Память и подтверждение действий
Агент покупок с `MemorySaver`, `interrupt_before=['tools']`, stream-выводом и чат-циклом.
## Требования
- Python 3.11+
- [LM Studio](https://lmstudio.ai/) с запущенным локальным API: `http://localhost:1234/v1`
## Установка
Проект использует **LangChain** и **LangGraph** (`MemorySaver`, прерывания перед tools).
Обязательно установите зависимости из `requirements.txt`, включая `langgraph>=1.0.8`:
```bash
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
# source .venv/bin/activate
pip install -r requirements.txt
```
Проверка, что `langgraph` установлен:
```bash
python -c "from langgraph.checkpoint.memory import MemorySaver; print('langgraph OK')"
```
## Запуск
1. Запустите LM Studio и загрузите модель (по умолчанию endpoint `http://localhost:1234/v1`).
2. При необходимости задайте переменные окружения:
```bash
set LM_STUDIO_BASE_URL=http://localhost:1234/v1
set LM_STUDIO_MODEL=local-model
set OPENAI_API_KEY=fake
```
3. Запустите агента:
```bash
python main.py
```
В чате введите запрос (например: «Сколько стоит молоко в Казани?»).
При вызове инструмента агент спросит подтверждение: `Y` — разрешить, иначе — отмена.
Выход: `exit`.