Spaces:
Sleeping
Sleeping
|
Download data/tutorials/human_in_the_loop.md from nvikou/techdocs-graphrag: direct link, hf CLI and curl.
- Browser
- Download file 878 Bytes
-
https://huggingface.co/spaces/nvikou/techdocs-graphrag/resolve/main/data/tutorials/human_in_the_loop.md
- Command line
-
hf download hf://spaces/nvikou/techdocs-graphrag/data/tutorials/human_in_the_loop.md
-
curl -L -o human_in_the_loop.md https://huggingface.co/spaces/nvikou/techdocs-graphrag/resolve/main/data/tutorials/human_in_the_loop.md
878 Bytes
| # Tutoriel : Human-in-the-loop | |
| Le Human-in-the-loop permet de mettre un workflow en pause pour obtenir une validation humaine. | |
| La fonction interrupt suspend l'exécution d'un Node et renvoie une valeur à l'appelant. | |
| La fonction interrupt nécessite un Checkpointer, car l'état doit être sauvegardé pendant la pause. | |
| Pour reprendre, on invoque le graphe avec Command(resume=valeur) et le même thread_id. | |
| Le Node interrompu redémarre et interrupt renvoie la valeur fournie par l'humain. | |
| ```python | |
| from langgraph.types import interrupt, Command | |
| def review(state): | |
| decision = interrupt({"draft": state["draft"]}) | |
| return {"approved": decision == "ok"} | |
| graph.invoke(Command(resume="ok"), config) | |
| ``` | |
| Les paramètres interrupt_before et interrupt_after de compile permettent aussi de s'arrêter | |
| avant ou après des Nodes précis, principalement pour le débogage. | |