diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 61f72e222b3..8599c6fe1f6 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -5510,6 +5510,8 @@ class ProxyConfig: parse_budget_reset_time(value) setattr(litellm, key, value) + elif key == "prometheus_emit_input_sequence_length_label": + self._apply_safe_litellm_setting_override(key, value) else: verbose_proxy_logger.debug( "%s setting litellm.%s=%s%s", diff --git a/tests/test_litellm/proxy/proxy_server/test_proxy_config.py b/tests/test_litellm/proxy/proxy_server/test_proxy_config.py index 8e8406d564f..9b27f8e3ceb 100644 --- a/tests/test_litellm/proxy/proxy_server/test_proxy_config.py +++ b/tests/test_litellm/proxy/proxy_server/test_proxy_config.py @@ -11,6 +11,7 @@ from __future__ import annotations import json import os import re +from pathlib import Path from types import SimpleNamespace from typing import Any, Dict, Final from unittest.mock import AsyncMock, MagicMock @@ -1158,6 +1159,28 @@ async def test_ProxyConfig_load_config_builds_the_secret_manager_exactly_once(tm } == {"constructions": 1, "master_key": "master-from-vault"} +@pytest.mark.asyncio +@pytest.mark.parametrize(("raw_value", "expected"), (("true", True), ("false", False))) +async def test_load_config_normalizes_hosted_input_sequence_length_flag( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, raw_value: str, expected: bool +) -> None: + monkeypatch.setattr(litellm, "prometheus_emit_input_sequence_length_label", not expected) + monkeypatch.delenv("PROM_FLAG", raising=False) + config_yaml: Final = ( + VAULT_BACKED_CONFIG.replace("master_key: os.environ/LITELLM_MASTER_KEY", "master_key: null") + .replace(" - MY_PROVIDER_KEY", " - MY_PROVIDER_KEY\n - PROM_FLAG") + + "\nlitellm_settings:\n prometheus_emit_input_sequence_length_label: os.environ/PROM_FLAG\n" + ) + config_file_path: Final = _write_vault_backed_config(tmp_path, monkeypatch, config_yaml) + (tmp_path / "vault_secret_manager.py").write_text( + VAULT_SECRET_MANAGER_MODULE + f"\nVAULT['PROM_FLAG'] = {raw_value!r}\n" + ) + + await ProxyConfig().load_config(router=None, config_file_path=config_file_path) + + assert litellm.prometheus_emit_input_sequence_length_label is expected + + @pytest.mark.asyncio async def test_ProxyConfig_get_config_reuses_an_already_initialized_secret_manager(tmp_path, monkeypatch): """get_config() also runs on management-endpoint request paths.