from_env#
- langchain_core.utils.utils.from_env(key: str, /) Callable[[], str] [source]#
- langchain_core.utils.utils.from_env(key: str, /, *, default: str) Callable[[], str]
- langchain_core.utils.utils.from_env(key: Sequence[str], /, *, default: str) Callable[[], str]
- langchain_core.utils.utils.from_env(key: str, /, *, error_message: str) Callable[[], str]
- langchain_core.utils.utils.from_env(key: str | Sequence[str], /, *, default: str, error_message: str | None) Callable[[], str]
- langchain_core.utils.utils.from_env(key: str, /, *, default: None, error_message: str | None) Callable[[], str | None]
- langchain_core.utils.utils.from_env(key: str | Sequence[str], /, *, default: None) Callable[[], str | None]
Create a factory method that gets a value from an environment variable.
- Parameters:
key – The environment variable to look up. If a list of keys is provided, the first key found in the environment will be used. If no key is found, the default value will be used if set, otherwise an error will be raised.
default – The default value to return if the environment variable is not set.
error_message – the error message which will be raised if the key is not found and no default value is provided. This will be raised as a ValueError.