Skip to navigation

nemoguardrails.deprecation

View as MarkdownOpen in Claude

Removal warnings for what leaves with the LLMRails engine: direct LLMRails use and Colang 2.x.

Module Contents

Classes

NameDescription
LLMRailsRemovalWarningA feature that is removed together with the LLMRails engine.

Functions

NameDescription
_is_package_file-
_stacklevel_outside_packageReturn the stacklevel, counted from warn_at_caller_outside_package, of the nearest frame outside the package.
called_from_packageReturn True when the function calling this one was itself called from inside the nemoguardrails package.
llmrails_removal_messageReturn the removal notice for subject, naming alternative as the way forward.
removal_warnings_silencedSilence LLMRailsRemovalWarnings in the block, so that one construction emits at most one.
warn_at_caller_outside_packageEmit message as category, attributed to the nearest caller outside the nemoguardrails package.
warn_llmrails_removalEmit an LLMRailsRemovalWarning attributed to the nearest caller outside the nemoguardrails package.

Data

COLANG_2_ALTERNATIVE

DEPRECATED_SINCE

REMOVAL_RELEASE

_PACKAGE_DIR

_removal_warnings_silenced

API

class nemoguardrails.LLMRailsRemovalWarning()

Bases: DeprecationWarning

A feature that is removed together with the LLMRails engine.

nemoguardrails.deprecation._is_package_file(
filename: str
) -> bool
nemoguardrails.deprecation._stacklevel_outside_package() -> int

Return the stacklevel, counted from warn_at_caller_outside_package, of the nearest frame outside the package.

nemoguardrails.deprecation.called_from_package() -> bool

Return True when the function calling this one was itself called from inside the nemoguardrails package.

nemoguardrails.deprecation.llmrails_removal_message(
subject: str,
alternative: str
) -> str

Return the removal notice for subject, naming alternative as the way forward.

nemoguardrails.deprecation.removal_warnings_silenced() -> typing.Iterator[None]

Silence LLMRailsRemovalWarnings in the block, so that one construction emits at most one.

nemoguardrails.deprecation.warn_at_caller_outside_package(
message: str,
category: type[Warning]
) -> None

Emit message as category, attributed to the nearest caller outside the nemoguardrails package.

nemoguardrails.deprecation.warn_llmrails_removal(
subject: str,
alternative: str
) -> None

Emit an LLMRailsRemovalWarning attributed to the nearest caller outside the nemoguardrails package.

nemoguardrails.deprecation.COLANG_2_ALTERNATIVE = 'IORails will not support Colang 2.x, so there is no replacement.'
nemoguardrails.deprecation.DEPRECATED_SINCE = '0.25.0'
nemoguardrails.deprecation.REMOVAL_RELEASE = '0.27.0'
nemoguardrails.deprecation._PACKAGE_DIR = os.path.dirname(os.path.realpath(__file__)) + os.sep
nemoguardrails.deprecation._removal_warnings_silenced: ContextVar[bool] = ContextVar('llmrails_removal_warnings_silenced', default=False)