nat.llm.utils.env_config_value#

Classes#

EnvConfigValueSource

Sources from which an environment-backed config value can be loaded.

EnvConfigValue

A wrapper for a string used as a configuration value which can be loaded from the system environment or injected via

Module Contents#

class EnvConfigValueSource(*args, \*\*kwds)#

Bases: enum.Enum

Sources from which an environment-backed config value can be loaded.

ENV_DEFAULT = 1#
CONSTRUCTOR = 2#
ENV_OVERRIDE = 3#
class EnvConfigValue(value: str | None = None, use_env: bool = True)#

Bases: abc.ABC

A wrapper for a string used as a configuration value which can be loaded from the system environment or injected via the constructor. This class should be subclassed and the class fields _ENV_KEY and _ENV_KEY_OVERRIDE can be set to enable environment-loading functionality. Convienience properties are available to check from where the value was loaded.

Parameters#

valuestr, optional

The value to be contained in the EnvConfigValue. If the value is None, an attempt will be made to load it from the environment using _ENV_KEY. if the _ENV_KEY_OVERRIDE field is not None, an attempt will be made to load that environment variable in place of the passed-in value.

use_envbool

If False, all environment-loading logic will be bypassed and the passed-in value will be used as-is. defaults to True.

_ENV_KEY: str | None = None#
_ENV_KEY_OVERRIDE: str | None = None#
_ALLOW_NONE: bool = False#
_source#
_value = None#
_use_env = True#
property source: EnvConfigValueSource#
property use_env: bool#
property value: str | None#