mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
cr
This commit is contained in:
File diff suppressed because one or more lines are too long
+1
-2
@@ -413,8 +413,7 @@
|
||||
" print(f\"Output from node '{key}':\")\n",
|
||||
" print(\"---\")\n",
|
||||
" print(value)\n",
|
||||
" print(\"\\n---\\n\")\n",
|
||||
" history= output['__end__']"
|
||||
" print(\"\\n---\\n\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
from langgraph.graph.graph import END, Graph
|
||||
from langgraph.graph.graph import END, Graph, START
|
||||
from langgraph.graph.message import MessageGraph
|
||||
from langgraph.graph.state import StateGraph
|
||||
|
||||
__all__ = ["END", "Graph", "StateGraph", "MessageGraph"]
|
||||
__all__ = ["END", "START", "Graph", "StateGraph", "MessageGraph"]
|
||||
|
||||
@@ -13,6 +13,7 @@ from langgraph.checkpoint import BaseCheckpointSaver
|
||||
from langgraph.pregel import Channel, Pregel
|
||||
|
||||
END = "__end__"
|
||||
START = "START"
|
||||
|
||||
|
||||
class Branch(NamedTuple):
|
||||
@@ -34,6 +35,7 @@ class Graph:
|
||||
self.edges = set[tuple[str, str]]()
|
||||
self.branches: defaultdict[str, list[Branch]] = defaultdict(list)
|
||||
self.support_multiple_edges = False
|
||||
self.entry_point = None
|
||||
|
||||
def add_node(self, key: str, action: RunnableLike) -> None:
|
||||
if key in self.nodes:
|
||||
@@ -85,6 +87,12 @@ class Graph:
|
||||
raise ValueError(f"Need to add_node `{key}` first")
|
||||
self.entry_point = key
|
||||
|
||||
def set_entry_route(self, condition: Callable[..., str],
|
||||
conditional_edge_mapping: Optional[Dict[str, str]] = None) -> None:
|
||||
self.add_node(START, lambda x: None)
|
||||
self.add_conditional_edges(START, condition, conditional_edge_mapping)
|
||||
self.set_entry_point(START)
|
||||
|
||||
def set_finish_point(self, key: str) -> None:
|
||||
return self.add_edge(key, END)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user