Home / Function/ get_graph() — langchain Function Reference

get_graph() — langchain Function Reference

Architecture documentation for the get_graph() function in base.py from the langchain codebase.

Function python LangChainCore Runnables calls 4 called by 2

Entity Profile

Dependency Diagram

graph TD
  0d15d94e_1356_d663_2931_94fce971d5bd["get_graph()"]
  4a62481c_02cb_a5de_1833_50669d5351a6["Runnable"]
  0d15d94e_1356_d663_2931_94fce971d5bd -->|defined in| 4a62481c_02cb_a5de_1833_50669d5351a6
  355a6334_f5bf_d779_2051_cecbe0cbd12b["get_prompts()"]
  355a6334_f5bf_d779_2051_cecbe0cbd12b -->|calls| 0d15d94e_1356_d663_2931_94fce971d5bd
  3fc77054_a9db_4f51_31ed_c1057170c9d7["get_graph()"]
  3fc77054_a9db_4f51_31ed_c1057170c9d7 -->|calls| 0d15d94e_1356_d663_2931_94fce971d5bd
  08435009_1486_e4f9_5312_91db7c8545a0["get_input_schema()"]
  0d15d94e_1356_d663_2931_94fce971d5bd -->|calls| 08435009_1486_e4f9_5312_91db7c8545a0
  255c479b_b9fa_44d8_4de5_2562051e06b5["get_name()"]
  0d15d94e_1356_d663_2931_94fce971d5bd -->|calls| 255c479b_b9fa_44d8_4de5_2562051e06b5
  310f6e6e_dbfb_7eb4_3854_6fc149d866c4["get_output_schema()"]
  0d15d94e_1356_d663_2931_94fce971d5bd -->|calls| 310f6e6e_dbfb_7eb4_3854_6fc149d866c4
  3fc77054_a9db_4f51_31ed_c1057170c9d7["get_graph()"]
  0d15d94e_1356_d663_2931_94fce971d5bd -->|calls| 3fc77054_a9db_4f51_31ed_c1057170c9d7
  style 0d15d94e_1356_d663_2931_94fce971d5bd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/base.py lines 584–603

    def get_graph(self, config: RunnableConfig | None = None) -> Graph:
        """Return a graph representation of this `Runnable`."""
        # Import locally to prevent circular import
        from langchain_core.runnables.graph import Graph  # noqa: PLC0415

        graph = Graph()
        try:
            input_node = graph.add_node(self.get_input_schema(config))
        except TypeError:
            input_node = graph.add_node(create_model_v2(self.get_name("Input")))
        runnable_node = graph.add_node(
            self, metadata=config.get("metadata") if config else None
        )
        try:
            output_node = graph.add_node(self.get_output_schema(config))
        except TypeError:
            output_node = graph.add_node(create_model_v2(self.get_name("Output")))
        graph.add_edge(input_node, runnable_node)
        graph.add_edge(runnable_node, output_node)
        return graph

Domain

Subdomains

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 584.
What does get_graph() call?
get_graph() calls 4 function(s): get_graph, get_input_schema, get_name, get_output_schema.
What calls get_graph()?
get_graph() is called by 2 function(s): get_graph, get_prompts.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free