Files

28 lines
1.2 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.
# FAQ: LangGraph
## Что такое StateGraph?
StateGraph — основной класс для построения графа состояний.
State — TypedDict, nodes — функции, edges — переходы между узлами.
## Как добавить узел в граф?
```python
builder = StateGraph(MyState)
builder.add_node("my_node", my_function)
builder.add_edge(START, "my_node")
graph = builder.compile()
```
## Что такое условные рёбра?
add_conditional_edges позволяет выбирать следующий узел на основе состояния.
Роутер — функция которая возвращает строку с именем следующего узла.
## Как добавить память (checkpointer)?
```python
from langgraph.checkpoint.memory import MemorySaver
memory = MemorySaver()
graph = builder.compile(checkpointer=memory)
```
## Что такое interrupt?
interrupt() — остановка графа для подтверждения пользователя (humanintheloop).
После resume граф продолжает с того же места.