diff --git a/litellm/proxy/_lazy_openapi_snapshot.json b/litellm/proxy/_lazy_openapi_snapshot.json index 4b353976dbd..141adfeaa36 100644 --- a/litellm/proxy/_lazy_openapi_snapshot.json +++ b/litellm/proxy/_lazy_openapi_snapshot.json @@ -12077,8 +12077,8 @@ "title": "Metadata" }, "min_tokens": { - "default": 1000, - "description": "Skip the compression round trip when the compressible messages total fewer than this many tokens. 0 always calls the compression service.", + "default": 0, + "description": "Skip the compression round trip when the compressible messages total fewer than this many tokens. The default of 0 always calls the compression service.", "minimum": 0.0, "title": "Min Tokens", "type": "integer" diff --git a/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.py b/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.py index 6aaa24251c8..a5aa210a24b 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.py +++ b/litellm/proxy/guardrails/guardrail_hooks/headroom/headroom.py @@ -56,7 +56,6 @@ if TYPE_CHECKING: from litellm.types.proxy.guardrails.guardrail_hooks.base import GuardrailConfigModel BYPASS_HEADER: Final = "x-headroom-bypass" -DEFAULT_MIN_TOKENS: Final = 1000 _STREAM_CONVERTIBLE_CALL_TYPES: Final = frozenset( (CallTypes.completion, CallTypes.acompletion, CallTypes.responses, CallTypes.aresponses) ) @@ -515,7 +514,7 @@ class HeadroomGuardrail(CustomGuardrail): unreachable_fallback: str | None = None, timeout: float | None = None, ccr_retrieval: bool = True, - min_tokens: int | None = None, + min_tokens: int = 0, ): self.headroom_api_base = (api_base or get_secret_str("HEADROOM_API_BASE") or "").rstrip("/") if not self.headroom_api_base: @@ -530,7 +529,7 @@ class HeadroomGuardrail(CustomGuardrail): ) self.timeout: httpx.Timeout = self._resolve_timeout(timeout) self.ccr_retrieval = ccr_retrieval - self.min_tokens: int = DEFAULT_MIN_TOKENS if min_tokens is None else min_tokens + self.min_tokens = min_tokens self.async_handler = get_async_httpx_client( llm_provider=httpxSpecialProvider.GuardrailCallback, ) diff --git a/litellm/types/proxy/guardrails/guardrail_hooks/headroom.py b/litellm/types/proxy/guardrails/guardrail_hooks/headroom.py index 4d6057c5ebb..19c78adf39e 100644 --- a/litellm/types/proxy/guardrails/guardrail_hooks/headroom.py +++ b/litellm/types/proxy/guardrails/guardrail_hooks/headroom.py @@ -31,11 +31,11 @@ class HeadroomGuardrailConfigModel(GuardrailConfigModel[BaseModel]): description="Inject the Headroom retrieval tool for hashes declared by the compression service.", ) min_tokens: int = Field( - default=1000, + default=0, ge=0, description=( "Skip the compression round trip when the compressible messages total fewer than this many tokens. " - "0 always calls the compression service." + "The default of 0 always calls the compression service." ), ) diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.py index 39babe5b3f7..a87c13e80e2 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.py @@ -33,7 +33,6 @@ from fastapi import HTTPException import litellm from litellm.proxy.guardrails.guardrail_hooks.headroom.headroom import ( - DEFAULT_MIN_TOKENS, HEADROOM_RETRIEVE_TOOL_NAME, HeadroomGuardrail, has_headroom_retrieve_tool, @@ -1138,7 +1137,7 @@ def test_initialize_guardrail_passes_min_tokens(monkeypatch: pytest.MonkeyPatch) ) assert configured_guardrail.min_tokens == 42 - assert default_guardrail.min_tokens == DEFAULT_MIN_TOKENS + assert default_guardrail.min_tokens == 0 @pytest.mark.asyncio diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts index 5b5b86046df..173fb45b0af 100644 --- a/ui/litellm-dashboard/src/lib/http/schema.d.ts +++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts @@ -32341,8 +32341,8 @@ export interface components { } | null; /** * Min Tokens - * @description Skip the compression round trip when the compressible messages total fewer than this many tokens. 0 always calls the compression service. - * @default 1000 + * @description Skip the compression round trip when the compressible messages total fewer than this many tokens. The default of 0 always calls the compression service. + * @default 0 */ min_tokens: number; /**