Home / Function/ __init__() — langchain Function Reference

__init__() — langchain Function Reference

Architecture documentation for the __init__() function in caches.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  36c2f95a_bd4e_24dd_aa24_33b803be1dc3["__init__()"]
  4d0ff6e4_41b7_2651_42a4_d1f2735b32e1["InMemoryCache"]
  36c2f95a_bd4e_24dd_aa24_33b803be1dc3 -->|defined in| 4d0ff6e4_41b7_2651_42a4_d1f2735b32e1
  style 36c2f95a_bd4e_24dd_aa24_33b803be1dc3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/caches.py lines 182–199

    def __init__(self, *, maxsize: int | None = None) -> None:
        """Initialize with empty cache.

        Args:
            maxsize: The maximum number of items to store in the cache.

                If `None`, the cache has no maximum size.

                If the cache exceeds the maximum size, the oldest items are removed.

        Raises:
            ValueError: If `maxsize` is less than or equal to `0`.
        """
        self._cache: dict[tuple[str, str], RETURN_VAL_TYPE] = {}
        if maxsize is not None and maxsize <= 0:
            msg = "maxsize must be greater than 0"
            raise ValueError(msg)
        self._maxsize = maxsize

Domain

Subdomains

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/core/langchain_core/caches.py.
Where is __init__() defined?
__init__() is defined in libs/core/langchain_core/caches.py at line 182.

Analyze Your Own Codebase

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

Try Supermodel Free