Merge pull request #442 from langchain-ai/nc/13may/small-fixes

Small fixes while migrating JS
This commit is contained in:
Nuno Campos
2024-05-14 10:13:28 -07:00
committed by GitHub
4 changed files with 8 additions and 11 deletions
+3 -1
View File
@@ -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:
+4 -3
View File
@@ -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
+1 -1
View File
@@ -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))
-6
View File
@@ -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