mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-17 23:51:30 +00:00
The merge base read the variable by truthiness, so any non-empty value turned the global flag on. Parsing it as a flag made a value such as temperature or enabled silently turn it off, and the only docs for the variable describe it as a list of parameter names, so keep those values on and log a warning that asks for true or false. A blank value stays off without a warning
33 lines
1 KiB
Python
33 lines
1 KiB
Python
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
|
|
def _import_litellm_with(configured: str) -> subprocess.CompletedProcess[str]:
|
|
return subprocess.run(
|
|
[sys.executable, "-c", "import litellm; print(litellm.drop_params)"],
|
|
env={**os.environ, "LITELLM_DROP_PARAMS": configured},
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("configured, expected", [("false", "False"), ("true", "True"), ("", "False")])
|
|
def test_litellm_drop_params_env_var_is_parsed_as_a_flag(configured, expected):
|
|
result = _import_litellm_with(configured)
|
|
|
|
assert result.stdout.strip() == expected
|
|
assert "is not a flag value" not in result.stderr
|
|
|
|
|
|
def test_litellm_drop_params_env_var_non_flag_value_stays_on_with_a_warning():
|
|
result = _import_litellm_with("temperature")
|
|
|
|
assert result.stdout.strip() == "True"
|
|
assert (
|
|
"LITELLM_DROP_PARAMS='temperature' is not a flag value, treating it as on. Set it to true or false"
|
|
in result.stderr
|
|
)
|