Spaces:
Sleeping
Sleeping
|
Download data/tutorials/persistence.md from nvikou/techdocs-graphrag: direct link, hf CLI and curl.
- Browser
- Download file 796 Bytes
-
https://huggingface.co/spaces/nvikou/techdocs-graphrag/resolve/main/data/tutorials/persistence.md
- Command line
-
hf download hf://spaces/nvikou/techdocs-graphrag/data/tutorials/persistence.md
-
curl -L -o persistence.md https://huggingface.co/spaces/nvikou/techdocs-graphrag/resolve/main/data/tutorials/persistence.md
796 Bytes
| # Tutoriel : persister un workflow | |
| Ce tutoriel montre comment rendre un StateGraph persistant. | |
| Étape 1 : choisir un Checkpointer. En développement, InMemorySaver suffit. | |
| En production, PostgresSaver garantit que l'état survit au redémarrage du serveur. | |
| Étape 2 : passer le Checkpointer à la méthode compile. | |
| ```python | |
| from langgraph.checkpoint.memory import InMemorySaver | |
| graph = builder.compile(checkpointer=InMemorySaver()) | |
| ``` | |
| Étape 3 : fournir un thread_id à chaque appel. | |
| Deux appels avec le même thread_id partagent le même état ; le Channel messages conserve l'historique | |
| grâce au Reducer add_messages. | |
| Étape 4 : inspecter l'état avec get_state pour vérifier ce qui a été sauvegardé. | |
| Sans Checkpointer, un StateGraph repart d'un état vide à chaque invocation. | |