mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-11 04:07:52 +02:00
Fix
This commit is contained in:
@@ -34,7 +34,7 @@ from langgraph.utils.runnable import (
|
||||
)
|
||||
|
||||
Writer = Callable[
|
||||
[Sequence[Union[str, Send]]],
|
||||
[Sequence[Union[str, Send]], bool],
|
||||
Sequence[Union[ChannelWriteEntry, Send]],
|
||||
]
|
||||
|
||||
@@ -142,7 +142,7 @@ class Branch(NamedTuple):
|
||||
),
|
||||
list(
|
||||
zip_longest(
|
||||
writer([e for e in self.ends.values()]),
|
||||
writer([e for e in self.ends.values()], True),
|
||||
[str(la) for la, e in self.ends.items()],
|
||||
)
|
||||
)
|
||||
@@ -211,12 +211,11 @@ class Branch(NamedTuple):
|
||||
]
|
||||
else:
|
||||
destinations = cast(Sequence[Union[Send, str]], result)
|
||||
destinations = [d for d in destinations if d != END]
|
||||
if any(dest is None or dest == START for dest in destinations):
|
||||
raise ValueError("Branch did not return a valid destination")
|
||||
if any(p.node == END for p in destinations if isinstance(p, Send)):
|
||||
raise InvalidUpdateError("Cannot send a packet to the END node")
|
||||
entries = writer(destinations)
|
||||
entries = writer(destinations, False)
|
||||
if not entries:
|
||||
return input
|
||||
else:
|
||||
|
||||
@@ -374,7 +374,7 @@ class CompiledGraph(Pregel):
|
||||
|
||||
def attach_branch(self, start: str, name: str, branch: Branch) -> None:
|
||||
def get_writes(
|
||||
packets: Sequence[Union[str, Send]],
|
||||
packets: Sequence[Union[str, Send]], static: bool = False
|
||||
) -> Sequence[Union[ChannelWriteEntry, Send]]:
|
||||
return [
|
||||
(
|
||||
|
||||
@@ -843,7 +843,7 @@ class CompiledStateGraph(CompiledGraph):
|
||||
self, start: str, name: str, branch: Branch, *, with_reader: bool = True
|
||||
) -> None:
|
||||
def get_writes(
|
||||
packets: Sequence[Union[str, Send]],
|
||||
packets: Sequence[Union[str, Send]], static: bool = False
|
||||
) -> Sequence[Union[ChannelWriteEntry, Send]]:
|
||||
writes = [
|
||||
(
|
||||
@@ -852,7 +852,10 @@ class CompiledStateGraph(CompiledGraph):
|
||||
else p
|
||||
)
|
||||
for p in packets
|
||||
if (True if static else p != END)
|
||||
]
|
||||
if not writes:
|
||||
return []
|
||||
if branch.then and branch.then != END:
|
||||
writes.append(
|
||||
ChannelWriteEntry(
|
||||
|
||||
Reference in New Issue
Block a user