graph.py — langchain Source File
Architecture documentation for graph.py, a python file in the langchain codebase. 14 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 81a6280b_4752_84db_f1fa_1a3b8040d481["graph.py"] 589b2e2f_c593_ed0a_7906_df4ca371d542["inspect"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 589b2e2f_c593_ed0a_7906_df4ca371d542 9cec496e_5583_62d2_b4a1_469bbdaf601f["collections"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 9cec496e_5583_62d2_b4a1_469bbdaf601f cd5f8820_9b2e_4495_abb7_d76026ac826c["dataclasses"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> cd5f8820_9b2e_4495_abb7_d76026ac826c 7ec08df6_88bd_07ab_d50f_0d4c4e429b7e["enum"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 7ec08df6_88bd_07ab_d50f_0d4c4e429b7e feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> feec1ec4_6917_867b_d228_b134d0ff8099 02f66451_d2a9_e7c3_9765_c3a7594721ad["uuid"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 02f66451_d2a9_e7c3_9765_c3a7594721ad e082ede2_868f_7149_8977_a2af7e5aeb38["langchain_core.load.serializable"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> e082ede2_868f_7149_8977_a2af7e5aeb38 15b6f2ac_8a3b_5719_0e4d_4652995195ed["langchain_core.runnables.base"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 15b6f2ac_8a3b_5719_0e4d_4652995195ed 314b1cc1_bd2e_bf43_4c2f_8c292c35f3e7["langchain_core.utils.pydantic"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 314b1cc1_bd2e_bf43_4c2f_8c292c35f3e7 2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 2bf6d401_816d_d011_3b05_a6114f55ff58 dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> dd5e7909_a646_84f1_497b_cae69735550e d40a481e_a2a3_424d_2d6d_f24c448f6e9c["langchain_core.runnables.graph_ascii"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> d40a481e_a2a3_424d_2d6d_f24c448f6e9c 6ddd15a0_3f9f_4cd8_0f72_be6ca4d23064["langchain_core.runnables.graph_png"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 6ddd15a0_3f9f_4cd8_0f72_be6ca4d23064 5078e88d_7ff8_afba_5113_31a55cc87fa6["langchain_core.runnables.graph_mermaid"] 81a6280b_4752_84db_f1fa_1a3b8040d481 --> 5078e88d_7ff8_afba_5113_31a55cc87fa6 style 81a6280b_4752_84db_f1fa_1a3b8040d481 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Graph used in `Runnable` objects."""
from __future__ import annotations
import inspect
from collections import defaultdict
from dataclasses import dataclass, field
from enum import Enum
from typing import (
TYPE_CHECKING,
Any,
NamedTuple,
Protocol,
TypedDict,
overload,
)
from uuid import UUID, uuid4
from langchain_core.load.serializable import to_json_not_implemented
from langchain_core.runnables.base import Runnable, RunnableSerializable
from langchain_core.utils.pydantic import _IgnoreUnserializable, is_basemodel_subclass
if TYPE_CHECKING:
from collections.abc import Callable, Sequence
from pydantic import BaseModel
from langchain_core.runnables.base import Runnable as RunnableType
class Stringifiable(Protocol):
"""Protocol for objects that can be converted to a string."""
def __str__(self) -> str:
"""Convert the object to a string."""
class LabelsDict(TypedDict):
"""Dictionary of labels for nodes and edges in a graph."""
nodes: dict[str, str]
"""Labels for nodes."""
edges: dict[str, str]
"""Labels for edges."""
def is_uuid(value: str) -> bool:
"""Check if a string is a valid UUID.
Args:
value: The string to check.
Returns:
`True` if the string is a valid UUID, `False` otherwise.
"""
try:
UUID(value)
except ValueError:
return False
return True
// ... (680 more lines)
Domain
Subdomains
Dependencies
- collections
- collections.abc
- dataclasses
- enum
- inspect
- langchain_core.load.serializable
- langchain_core.runnables.base
- langchain_core.runnables.graph_ascii
- langchain_core.runnables.graph_mermaid
- langchain_core.runnables.graph_png
- langchain_core.utils.pydantic
- pydantic
- typing
- uuid
Source
Frequently Asked Questions
What does graph.py do?
graph.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in graph.py?
graph.py defines 6 function(s): _first_node, _last_node, collections, is_uuid, node_data_json, node_data_str.
What does graph.py depend on?
graph.py imports 14 module(s): collections, collections.abc, dataclasses, enum, inspect, langchain_core.load.serializable, langchain_core.runnables.base, langchain_core.runnables.graph_ascii, and 6 more.
Where is graph.py in the architecture?
graph.py is located at libs/core/langchain_core/runnables/graph.py (domain: LangChainCore, subdomain: Runnables, directory: libs/core/langchain_core/runnables).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free