Spaces:
Sleeping
Sleeping
|
Download data/stategraph.md from nvikou/techdocs-graphrag: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/nvikou/techdocs-graphrag/resolve/main/data/stategraph.md
- Command line
-
hf download hf://spaces/nvikou/techdocs-graphrag/data/stategraph.md
-
curl -L -o stategraph.md https://huggingface.co/spaces/nvikou/techdocs-graphrag/resolve/main/data/stategraph.md
1.1 kB
| # StateGraph | |
| StateGraph est la classe centrale de LangGraph pour construire des workflows orientés état. | |
| Un StateGraph est paramétré par un schéma d'état, généralement un TypedDict ou un modèle Pydantic. | |
| StateGraph utilise des Channels pour stocker et transmettre l'état entre les nodes. | |
| Chaque clé du schéma d'état correspond à un Channel. | |
| Un StateGraph contient des Nodes reliés par des Edges. | |
| La méthode add_node enregistre un Node, la méthode add_edge crée un Edge fixe | |
| et la méthode add_conditional_edges crée un routage dynamique. | |
| Avant l'exécution, un StateGraph doit être compilé avec la méthode compile. | |
| La méthode compile retourne un CompiledGraph qui expose invoke, stream et get_state. | |
| La méthode compile accepte un paramètre checkpointer. | |
| Un StateGraph compilé avec un Checkpointer persiste son état entre plusieurs exécutions. | |
| ```python | |
| from langgraph.graph import StateGraph, START, END | |
| builder = StateGraph(State) | |
| builder.add_node("agent", call_model) | |
| builder.add_edge(START, "agent") | |
| builder.add_edge("agent", END) | |
| graph = builder.compile() | |
| ``` | |