diff --git a/gptqmodel/utils/env.py b/gptqmodel/utils/env.py new file mode 100644 index 000000000..2b1e85535 --- /dev/null +++ b/gptqmodel/utils/env.py @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2024-2025 ModelCloud.ai +# SPDX-FileCopyrightText: 2024-2025 qubitium@modelcloud.ai +# SPDX-License-Identifier: Apache-2.0 +# Contact: qubitium@modelcloud.ai, x.com/qubitium + +"""Environment variable helpers used across GPTQModel.""" + +from __future__ import annotations + +import os + +_TRUTHY = {"1", "true", "yes", "on", "y"} + + +def env_flag(name: str, default: str | None = "0") -> bool: + """Return ``True`` when an env var is set to a truthy value.""" + + value = os.getenv(name, default) + if value is None: + return False + return value.strip().lower() in _TRUTHY + + +__all__ = ["env_flag"]