Home / File/ beta_decorator.py — langchain Source File

beta_decorator.py — langchain Source File

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

File python CoreAbstractions Serialization 7 imports 4 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  99630651_1456_c882_1b50_48e292b442ff["beta_decorator.py"]
  69e1d8cc_6173_dcd0_bfdf_2132d8e1ce56["contextlib"]
  99630651_1456_c882_1b50_48e292b442ff --> 69e1d8cc_6173_dcd0_bfdf_2132d8e1ce56
  c990f2d7_9509_7cea_ca95_51ad57dbe5c6["functools"]
  99630651_1456_c882_1b50_48e292b442ff --> c990f2d7_9509_7cea_ca95_51ad57dbe5c6
  614e7b9f_ed51_0780_749c_ff40b74963fc["inspect"]
  99630651_1456_c882_1b50_48e292b442ff --> 614e7b9f_ed51_0780_749c_ff40b74963fc
  0c635125_6987_b8b3_7ff7_d60249aecde7["warnings"]
  99630651_1456_c882_1b50_48e292b442ff --> 0c635125_6987_b8b3_7ff7_d60249aecde7
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  99630651_1456_c882_1b50_48e292b442ff --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  99630651_1456_c882_1b50_48e292b442ff --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  088dc464_814e_9f9a_381f_17ac2cfb4263["langchain_core._api.internal"]
  99630651_1456_c882_1b50_48e292b442ff --> 088dc464_814e_9f9a_381f_17ac2cfb4263
  style 99630651_1456_c882_1b50_48e292b442ff fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Helper functions for marking parts of the LangChain API as beta.

This module was loosely adapted from matplotlib's [`_api/deprecation.py`](https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/_api/deprecation.py)
module.

!!! warning

    This module is for internal use only. Do not use it in your own code. We may change
    the API at any time with no warning.
"""

import contextlib
import functools
import inspect
import warnings
from collections.abc import Callable, Generator
from typing import Any, TypeVar, cast

from langchain_core._api.internal import is_caller_internal


class LangChainBetaWarning(DeprecationWarning):
    """A class for issuing beta warnings for LangChain users."""


# PUBLIC API


T = TypeVar("T", bound=Callable[..., Any] | type)


def beta(
    *,
    message: str = "",
    name: str = "",
    obj_type: str = "",
    addendum: str = "",
) -> Callable[[T], T]:
    """Decorator to mark a function, a class, or a property as beta.

    When marking a classmethod, a staticmethod, or a property, the `@beta` decorator
    should go *under* `@classmethod` and `@staticmethod` (i.e., `beta` should directly
    decorate the underlying callable), but *over* `@property`.

    When marking a class `C` intended to be used as a base class in a multiple
    inheritance hierarchy, `C` *must* define an `__init__` method (if `C` instead
    inherited its `__init__` from its own base class, then `@beta` would mess up
    `__init__` inheritance when installing its own (annotation-emitting) `C.__init__`).

    Args:
        message: Override the default beta message.

            The %(since)s, %(name)s, %(alternative)s, %(obj_type)s, %(addendum)s, and
            %(removal)s format specifiers will be replaced by the values of the
            respective arguments passed to this function.
        name: The name of the beta object.
        obj_type: The object type being beta.
        addendum: Additional text appended directly to the final message.

    Returns:
// ... (194 more lines)

Subdomains

Dependencies

  • collections.abc
  • contextlib
  • functools
  • inspect
  • langchain_core._api.internal
  • typing
  • warnings

Frequently Asked Questions

What does beta_decorator.py do?
beta_decorator.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in beta_decorator.py?
beta_decorator.py defines 4 function(s): beta, suppress_langchain_beta_warning, surface_langchain_beta_warnings, warn_beta.
What does beta_decorator.py depend on?
beta_decorator.py imports 7 module(s): collections.abc, contextlib, functools, inspect, langchain_core._api.internal, typing, warnings.
Where is beta_decorator.py in the architecture?
beta_decorator.py is located at libs/core/langchain_core/_api/beta_decorator.py (domain: CoreAbstractions, subdomain: Serialization, 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