mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-31 12:19:58 +02:00
langgraph: allow setting custom names for compiled graph / compiled state graph (#3337)
This commit is contained in:
@@ -417,6 +417,7 @@ class Graph:
|
||||
interrupt_before: Optional[Union[All, list[str]]] = None,
|
||||
interrupt_after: Optional[Union[All, list[str]]] = None,
|
||||
debug: bool = False,
|
||||
name: Optional[str] = None,
|
||||
) -> "CompiledGraph":
|
||||
# assign default values
|
||||
interrupt_before = interrupt_before or []
|
||||
@@ -445,6 +446,7 @@ class Graph:
|
||||
interrupt_after_nodes=interrupt_after,
|
||||
auto_validate=False,
|
||||
debug=debug,
|
||||
name=name or "LangGraph",
|
||||
)
|
||||
|
||||
# attach nodes, edges, and branches
|
||||
|
||||
@@ -500,6 +500,7 @@ class StateGraph(Graph):
|
||||
interrupt_before: Optional[Union[All, list[str]]] = None,
|
||||
interrupt_after: Optional[Union[All, list[str]]] = None,
|
||||
debug: bool = False,
|
||||
name: Optional[str] = None,
|
||||
) -> "CompiledStateGraph":
|
||||
"""Compiles the state graph into a `CompiledGraph` object.
|
||||
|
||||
@@ -570,6 +571,7 @@ class StateGraph(Graph):
|
||||
auto_validate=False,
|
||||
debug=debug,
|
||||
store=store,
|
||||
name=name or "LangGraph",
|
||||
)
|
||||
|
||||
compiled.attach_node(START, None)
|
||||
|
||||
@@ -249,6 +249,7 @@ def create_react_agent(
|
||||
interrupt_after: Optional[list[str]] = None,
|
||||
debug: bool = False,
|
||||
version: Literal["v1", "v2"] = "v1",
|
||||
name: Optional[str] = None,
|
||||
) -> CompiledGraph:
|
||||
"""Creates a graph that works with a chat model that utilizes tool calling.
|
||||
|
||||
@@ -307,6 +308,9 @@ def create_react_agent(
|
||||
Tool calls are distributed across multiple instances of the tool
|
||||
node using the [Send](https://langchain-ai.github.io/langgraph/concepts/low_level/#send)
|
||||
API.
|
||||
name: An optional name for the CompiledStateGraph.
|
||||
This name will be automatically used when adding ReAct agent graph to another graph as a subgraph node -
|
||||
particularly useful for building multi-agent systems.
|
||||
|
||||
Returns:
|
||||
A compiled LangChain runnable that can be used for chat interactions.
|
||||
@@ -758,6 +762,7 @@ def create_react_agent(
|
||||
interrupt_before=interrupt_before,
|
||||
interrupt_after=interrupt_after,
|
||||
debug=debug,
|
||||
name=name,
|
||||
)
|
||||
|
||||
# Define the function that determines whether to continue or not
|
||||
@@ -834,6 +839,7 @@ def create_react_agent(
|
||||
interrupt_before=interrupt_before,
|
||||
interrupt_after=interrupt_after,
|
||||
debug=debug,
|
||||
name=name,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user