mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(proxy): normalize input length flag from secret managers
This commit is contained in:
parent
07f8a17fff
commit
87cce63a43
2 changed files with 25 additions and 0 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue