mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-09 11:17:53 +02:00
adding docs example
This commit is contained in:
@@ -440,6 +440,25 @@ Upon **resuming** the graph, the counter will be incremented a second time, resu
|
||||
The value of counter is: 2
|
||||
```
|
||||
|
||||
### Resuming multiple interrupts with one invocation
|
||||
|
||||
The [`Command`][langgraph.types.Command] constructor supports a [`resume_map`][langgraph.types.Command.resume_map] argument
|
||||
that you can use to specify a mapping of interrupt ids to their corresponding resume values.
|
||||
|
||||
This is helpful for the case of resuming multiple interrupts with a single invocation.
|
||||
For example, once your graph has been interrupted (multiple times, theoretically) and is paused:
|
||||
|
||||
```python
|
||||
resume_map: dict[str, Any] = {}
|
||||
for task in parent_graph.get_state(thread_config).tasks:
|
||||
for i in task.interrupts:
|
||||
resume_map[i.interrupt_id] = f"human input for prompt {i.value}"
|
||||
|
||||
parent_graph.invoke(Command(resume_map=resume_map), config=thread_config)
|
||||
```
|
||||
|
||||
Note, we plan to introduce an interrupts convenience attribute on `get_state()`'s result in the near future.
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
### Side-effects
|
||||
|
||||
Reference in New Issue
Block a user