beta() — langchain Function Reference
Architecture documentation for the beta() function in beta_decorator.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a46773f8_4c3d_a279_43db_daf6a5b4e0a6["beta()"] 99630651_1456_c882_1b50_48e292b442ff["beta_decorator.py"] a46773f8_4c3d_a279_43db_daf6a5b4e0a6 -->|defined in| 99630651_1456_c882_1b50_48e292b442ff 5b954159_166b_1d8d_a550_0870b51fa2dd["warn_beta()"] a46773f8_4c3d_a279_43db_daf6a5b4e0a6 -->|calls| 5b954159_166b_1d8d_a550_0870b51fa2dd style a46773f8_4c3d_a279_43db_daf6a5b4e0a6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/_api/beta_decorator.py lines 32–202
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:
A decorator which can be used to mark functions or classes as beta.
Example:
```python
@beta
def the_function_to_annotate():
pass
```
"""
def beta(
obj: T,
*,
_obj_type: str = obj_type,
_name: str = name,
_message: str = message,
_addendum: str = addendum,
) -> T:
"""Implementation of the decorator returned by `beta`."""
def emit_warning() -> None:
"""Emit the warning."""
warn_beta(
message=_message,
name=_name,
obj_type=_obj_type,
addendum=_addendum,
)
warned = False
def warning_emitting_wrapper(*args: Any, **kwargs: Any) -> Any:
"""Wrapper for the original wrapped callable that emits a warning.
Args:
*args: The positional arguments to the function.
**kwargs: The keyword arguments to the function.
Returns:
The return value of the function being wrapped.
"""
nonlocal warned
if not warned and not is_caller_internal():
warned = True
emit_warning()
return wrapped(*args, **kwargs)
async def awarning_emitting_wrapper(*args: Any, **kwargs: Any) -> Any:
"""Same as warning_emitting_wrapper, but for async functions."""
nonlocal warned
if not warned and not is_caller_internal():
warned = True
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does beta() do?
beta() is a function in the langchain codebase, defined in libs/core/langchain_core/_api/beta_decorator.py.
Where is beta() defined?
beta() is defined in libs/core/langchain_core/_api/beta_decorator.py at line 32.
What does beta() call?
beta() calls 1 function(s): warn_beta.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free