mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-10 19:57:52 +02:00
Move START & END to constants.py
This commit is contained in:
@@ -7,6 +7,9 @@ TASKS = "__pregel_tasks"
|
||||
RESERVED = {INTERRUPT, TASKS, CONFIG_KEY_SEND, CONFIG_KEY_READ}
|
||||
TAG_HIDDEN = "langsmith:hidden"
|
||||
|
||||
START = "__start__"
|
||||
END = "__end__"
|
||||
|
||||
|
||||
class Send:
|
||||
"""A message or packet to send to a specific node in the graph.
|
||||
|
||||
+11
-11
@@ -26,7 +26,7 @@ from langchain_core.runnables.graph import (
|
||||
|
||||
from langgraph.channels.ephemeral_value import EphemeralValue
|
||||
from langgraph.checkpoint import BaseCheckpointSaver
|
||||
from langgraph.constants import TAG_HIDDEN, Send
|
||||
from langgraph.constants import END, START, TAG_HIDDEN, Send
|
||||
from langgraph.errors import InvalidUpdateError
|
||||
from langgraph.pregel import Channel, Pregel
|
||||
from langgraph.pregel.read import PregelNode
|
||||
@@ -36,9 +36,6 @@ from langgraph.utils import DrawableGraph, RunnableCallable, coerce_to_runnable
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
START = "__start__"
|
||||
END = "__end__"
|
||||
|
||||
|
||||
class Branch(NamedTuple):
|
||||
path: Runnable[Any, Union[str, list[str]]]
|
||||
@@ -341,10 +338,11 @@ class Graph:
|
||||
|
||||
# validate the graph
|
||||
self.validate(
|
||||
interrupt=(interrupt_before if interrupt_before != "*" else [])
|
||||
+ interrupt_after
|
||||
if interrupt_after != "*"
|
||||
else []
|
||||
interrupt=(
|
||||
(interrupt_before if interrupt_before != "*" else []) + interrupt_after
|
||||
if interrupt_after != "*"
|
||||
else []
|
||||
)
|
||||
)
|
||||
|
||||
# create empty compiled graph
|
||||
@@ -404,9 +402,11 @@ class CompiledGraph(Pregel):
|
||||
def attach_branch(self, start: str, name: str, branch: Branch) -> None:
|
||||
def branch_writer(packets: list[Union[str, Send]]) -> Optional[ChannelWrite]:
|
||||
writes = [
|
||||
ChannelWriteEntry(f"branch:{start}:{name}:{p}" if p != END else END)
|
||||
if not isinstance(p, Send)
|
||||
else p
|
||||
(
|
||||
ChannelWriteEntry(f"branch:{start}:{name}:{p}" if p != END else END)
|
||||
if not isinstance(p, Send)
|
||||
else p
|
||||
)
|
||||
for p in packets
|
||||
]
|
||||
return ChannelWrite(writes, tags=[TAG_HIDDEN])
|
||||
|
||||
Reference in New Issue
Block a user