Home / File/ __init__.py — langchain Source File

__init__.py — langchain Source File

Architecture documentation for __init__.py, a python file in the langchain codebase. 5 imports, 0 dependents.

File python LangChainCore ApiManagement 5 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  a1f76670_9841_af32_e5be_02e7b2272945["__init__.py"]
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  a1f76670_9841_af32_e5be_02e7b2272945 --> feec1ec4_6917_867b_d228_b134d0ff8099
  aceeabcc_ceb9_769c_111a_10f5caa3b983["langchain_core._import_utils"]
  a1f76670_9841_af32_e5be_02e7b2272945 --> aceeabcc_ceb9_769c_111a_10f5caa3b983
  2863d467_b729_2c28_5e66_505e9257ffef["langchain_core._api.beta_decorator"]
  a1f76670_9841_af32_e5be_02e7b2272945 --> 2863d467_b729_2c28_5e66_505e9257ffef
  b869b9c1_fb7a_fbc5_c529_98b32cb76f64["langchain_core._api.deprecation"]
  a1f76670_9841_af32_e5be_02e7b2272945 --> b869b9c1_fb7a_fbc5_c529_98b32cb76f64
  28c5bc21_f33d_11a5_2838_3c72e1a7d4af["langchain_core._api.path"]
  a1f76670_9841_af32_e5be_02e7b2272945 --> 28c5bc21_f33d_11a5_2838_3c72e1a7d4af
  style a1f76670_9841_af32_e5be_02e7b2272945 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Helper functions for managing the LangChain API.

This module is only relevant for LangChain developers, not for users.

!!! warning

    This module and its submodules are for internal use only. Do not use them in your
    own code. We may change the API at any time with no warning.
"""

from typing import TYPE_CHECKING

from langchain_core._import_utils import import_attr

if TYPE_CHECKING:
    from langchain_core._api.beta_decorator import (
        LangChainBetaWarning,
        beta,
        suppress_langchain_beta_warning,
        surface_langchain_beta_warnings,
    )
    from langchain_core._api.deprecation import (
        LangChainDeprecationWarning,
        deprecated,
        suppress_langchain_deprecation_warning,
        surface_langchain_deprecation_warnings,
        warn_deprecated,
    )
    from langchain_core._api.path import as_import_path, get_relative_path

__all__ = (
    "LangChainBetaWarning",
    "LangChainDeprecationWarning",
    "as_import_path",
    "beta",
    "deprecated",
    "get_relative_path",
    "suppress_langchain_beta_warning",
    "suppress_langchain_deprecation_warning",
    "surface_langchain_beta_warnings",
    "surface_langchain_deprecation_warnings",
    "warn_deprecated",
)

_dynamic_imports = {
    "LangChainBetaWarning": "beta_decorator",
    "beta": "beta_decorator",
    "suppress_langchain_beta_warning": "beta_decorator",
    "surface_langchain_beta_warnings": "beta_decorator",
    "as_import_path": "path",
    "get_relative_path": "path",
    "LangChainDeprecationWarning": "deprecation",
    "deprecated": "deprecation",
    "surface_langchain_deprecation_warnings": "deprecation",
    "suppress_langchain_deprecation_warning": "deprecation",
    "warn_deprecated": "deprecation",
}


def __getattr__(attr_name: str) -> object:
    """Dynamically import and return an attribute from a submodule.

    This function enables lazy loading of API functions from submodules, reducing
    initial import time and circular dependency issues.

    Args:
        attr_name: Name of the attribute to import.

    Returns:
        The imported attribute object.

    Raises:
        AttributeError: If the attribute is not a valid dynamic import.
    """
    module_name = _dynamic_imports.get(attr_name)
    result = import_attr(attr_name, module_name, __spec__.parent)
    globals()[attr_name] = result
    return result


def __dir__() -> list[str]:
    """Return a list of available attributes for this module.

    Returns:
        List of attribute names that can be imported from this module.
    """
    return list(__all__)

Domain

Subdomains

Dependencies

  • langchain_core._api.beta_decorator
  • langchain_core._api.deprecation
  • langchain_core._api.path
  • langchain_core._import_utils
  • typing

Frequently Asked Questions

What does __init__.py do?
__init__.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, ApiManagement subdomain.
What functions are defined in __init__.py?
__init__.py defines 3 function(s): __dir__, __getattr__, langchain_core.
What does __init__.py depend on?
__init__.py imports 5 module(s): langchain_core._api.beta_decorator, langchain_core._api.deprecation, langchain_core._api.path, langchain_core._import_utils, typing.
Where is __init__.py in the architecture?
__init__.py is located at libs/core/langchain_core/_api/__init__.py (domain: LangChainCore, subdomain: ApiManagement, directory: libs/core/langchain_core/_api).

Analyze Your Own Codebase

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

Try Supermodel Free