Files
maratfazylov19 f4b9ee156c feat: текстовая игра на основе LLM + interrupt
- GameState (TypedDict) с полями: topic, setup, choices, selected_choice, ending
- story_node: генерация завязки → interrupt() → генерация концовки
- Цикл обработки __interrupt__ с Command(resume=...)
- Поддержка questionary и fallback на input()
- requirements.txt, .env.example, README.md
2026-05-08 17:17:41 +03:00

35 lines
1.1 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.
# Задание 4: Текстовая игра на основе LLM + interrupt
## Описание
Интерактивная история «выбери свою историю» с LangGraph:
- LLM придумывает завязку и 3 варианта поступка
- Граф ставит на паузу через `interrupt()`
- Пользователь выбирает вариант в консоли
- LLM дописывает концовку на основе выбора
## Стек
- Python 3.10+
- langchain-core, langchain-openai, langgraph, questionary
## Установка
```bash
pip install -r requirements.txt
cp .env.example .env
# Заполнить OPENAI_API_KEY в .env
```
## Запуск
```bash
python main.py "космический кот"
```
## Архитектура
- `GameState` — TypedDict с полями: topic, setup, choices, selected_choice, ending
- `story_node` — узел графа: генерация завязки → interrupt → генерация концовки
- `run_game()` — цикл: stream → обработка __interrupt__ → Command(resume=...) → результат