get_graph() — langchain Function Reference
Architecture documentation for the get_graph() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 92646703_74f4_de33_6f1d_887ee39c4db1["get_graph()"] c4bf8d59_69f9_f8e5_efba_837c20df2360["RunnableSequence"] 92646703_74f4_de33_6f1d_887ee39c4db1 -->|defined in| c4bf8d59_69f9_f8e5_efba_837c20df2360 dd68934b_b24b_922a_dfc2_d96ad2d88349["get_graph()"] 92646703_74f4_de33_6f1d_887ee39c4db1 -->|calls| dd68934b_b24b_922a_dfc2_d96ad2d88349 style 92646703_74f4_de33_6f1d_887ee39c4db1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/runnables/base.py lines 3036–3067
def get_graph(self, config: RunnableConfig | None = None) -> Graph:
"""Get the graph representation of the `Runnable`.
Args:
config: The config to use.
Returns:
The graph representation of the `Runnable`.
Raises:
ValueError: If a `Runnable` has no first or last node.
"""
# Import locally to prevent circular import
from langchain_core.runnables.graph import Graph # noqa: PLC0415
graph = Graph()
for step in self.steps:
current_last_node = graph.last_node()
step_graph = step.get_graph(config)
if step is not self.first:
step_graph.trim_first_node()
if step is not self.last:
step_graph.trim_last_node()
step_first_node, _ = graph.extend(step_graph)
if not step_first_node:
msg = f"Runnable {step} has no first node"
raise ValueError(msg)
if current_last_node:
graph.add_edge(current_last_node, step_first_node)
return graph
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does get_graph() do?
get_graph() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/base.py.
Where is get_graph() defined?
get_graph() is defined in libs/core/langchain_core/runnables/base.py at line 3036.
What does get_graph() call?
get_graph() calls 1 function(s): get_graph.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free