mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-12 12:47:53 +02:00
linting etc
This commit is contained in:
@@ -442,23 +442,20 @@ 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.
|
||||
If you have multiple interrupts in the task queue, you can use `Command.resume` with a dictionary mapping
|
||||
of interrupt ids to resume values to resume multiple interrupts with a single `invoke` / `stream` call.
|
||||
|
||||
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:
|
||||
For example, once your graph has been interrupted (multiple times, theoretically) and is stalled:
|
||||
|
||||
```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}"
|
||||
resume_map = {
|
||||
i.interrupt_id: f"human input for prompt {i.value}"
|
||||
for i in parent.get_state(thread_config).interrupts
|
||||
}
|
||||
|
||||
parent_graph.invoke(Command(resume_map=resume_map), config=thread_config)
|
||||
parent_graph.invoke(Command(resume=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
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
from collections import Counter
|
||||
from collections.abc import Iterator, Mapping, Sequence
|
||||
from typing import Any, Literal, Optional, TypeVar, Union
|
||||
from uuid import UUID
|
||||
|
||||
from langchain_core.runnables.utils import AddableDict
|
||||
|
||||
from langgraph.channels.base import BaseChannel, EmptyChannelError
|
||||
from langgraph.checkpoint.base import PendingWrite
|
||||
from langgraph.constants import (
|
||||
EMPTY_SEQ,
|
||||
ERROR,
|
||||
|
||||
Reference in New Issue
Block a user