Add stream-mode agent with messages and updates handling
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# Stream-режим AI-агента
|
||||
|
||||
Агент с потоковым выводом в консоль.
|
||||
|
||||
## Что реализовано
|
||||
|
||||
1. **`.stream()` вместо `.invoke()`** — `agent.stream(..., stream_mode=['messages', 'updates'])`
|
||||
2. **Обработка `'messages'`** — вывод токенов текста сразу (`end=''`), разделители `--- --- ---` при смене шага
|
||||
3. **Обработка `'updates'`** — отображение вызовов инструментов через `format_message()`
|
||||
|
||||
## Запуск
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
export OPENAI_API_KEY="your-key"
|
||||
python stream_agent.py
|
||||
```
|
||||
Reference in New Issue
Block a user