mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-26 17:42:24 +02:00
Merge pull request #442 from langchain-ai/nc/13may/small-fixes
Small fixes while migrating JS
This commit is contained in:
@@ -114,7 +114,9 @@ def create_checkpoint(
|
||||
) -> Checkpoint:
|
||||
"""Create a checkpoint for the given channels."""
|
||||
ts = datetime.now(timezone.utc).isoformat()
|
||||
assert ts > checkpoint["ts"], "Timestamps must be monotonically increasing"
|
||||
assert (
|
||||
ts > checkpoint["ts"]
|
||||
), f"Timestamps must be monotonically increasing, got {ts} <= {checkpoint['ts']}"
|
||||
values: dict[str, Any] = {}
|
||||
for k, v in channels.items():
|
||||
try:
|
||||
|
||||
@@ -242,12 +242,13 @@ class Graph:
|
||||
# assemble sources
|
||||
all_sources = {src for src, _ in self._all_edges}
|
||||
for start, branches in self.branches.items():
|
||||
all_sources.add(start)
|
||||
for cond, branch in branches.items():
|
||||
all_sources.add(start)
|
||||
if branch.then is not None:
|
||||
if branch.ends is not None:
|
||||
for end in branch.ends.values():
|
||||
all_sources.add(end)
|
||||
if end != END:
|
||||
all_sources.add(end)
|
||||
else:
|
||||
for node in self.nodes:
|
||||
if node != start and node != branch.then:
|
||||
@@ -257,7 +258,7 @@ class Graph:
|
||||
if node not in all_sources:
|
||||
raise ValueError(f"Node '{node}' is a dead-end")
|
||||
for source in all_sources:
|
||||
if node not in self.nodes and node != START:
|
||||
if node not in self.nodes and source != START:
|
||||
raise ValueError(f"Found edge starting at unknown node '{source}'")
|
||||
|
||||
# assemble targets
|
||||
|
||||
@@ -312,7 +312,7 @@ class CompiledStateGraph(CompiledGraph):
|
||||
elif end != END:
|
||||
# subscribe to start channel
|
||||
self.nodes[end].triggers.append(starts)
|
||||
else:
|
||||
elif end != END:
|
||||
channel_name = f"join:{'+'.join(starts)}:{end}"
|
||||
# register channel
|
||||
self.channels[channel_name] = NamedBarrierValue(str, set(starts))
|
||||
|
||||
@@ -108,12 +108,6 @@ WriteValue = Union[
|
||||
]
|
||||
|
||||
|
||||
def _coerce_write_value(value: WriteValue) -> Runnable[Input, Output]:
|
||||
if not isinstance(value, Runnable) and not callable(value):
|
||||
return coerce_to_runnable(lambda _: value)
|
||||
return coerce_to_runnable(value)
|
||||
|
||||
|
||||
class Channel:
|
||||
@overload
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user