mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-19 12:18:35 +00:00
fix(proxy): avoid duplicate reasoning capability lookup
Compute supports_reasoning once per non-wildcard health-check resolution path and update the stale default-max-tokens test docstring. Made-with: Cursor
This commit is contained in:
@@ -328,25 +328,19 @@ def _resolve_health_check_max_tokens(model_info: dict, litellm_params: dict) ->
|
||||
deployment_model = _deployment_model_string_for_health_check(litellm_params)
|
||||
|
||||
if not is_wildcard:
|
||||
try:
|
||||
is_reasoning = litellm.supports_reasoning(deployment_model)
|
||||
except Exception:
|
||||
is_reasoning = False
|
||||
tokens_reasoning = model_info.get("health_check_max_tokens_reasoning", None)
|
||||
tokens_non_reasoning = model_info.get(
|
||||
"health_check_max_tokens_non_reasoning", None
|
||||
)
|
||||
if tokens_reasoning is not None or tokens_non_reasoning is not None:
|
||||
try:
|
||||
is_reasoning = litellm.supports_reasoning(deployment_model)
|
||||
except Exception:
|
||||
is_reasoning = False
|
||||
if is_reasoning and tokens_reasoning is not None:
|
||||
return int(tokens_reasoning)
|
||||
if not is_reasoning and tokens_non_reasoning is not None:
|
||||
return int(tokens_non_reasoning)
|
||||
|
||||
if not is_wildcard:
|
||||
try:
|
||||
is_reasoning = litellm.supports_reasoning(deployment_model)
|
||||
except Exception:
|
||||
is_reasoning = False
|
||||
if (
|
||||
is_reasoning
|
||||
and BACKGROUND_HEALTH_CHECK_MAX_TOKENS_REASONING is not None
|
||||
|
||||
@@ -13,7 +13,7 @@ from litellm.proxy.health_check import (
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_litellm_params_max_tokens_default(monkeypatch):
|
||||
"""
|
||||
Test that max_tokens defaults to 1 for non-wildcard models.
|
||||
Test that max_tokens defaults to 5 for non-wildcard models.
|
||||
"""
|
||||
monkeypatch.setattr(hc_module, "BACKGROUND_HEALTH_CHECK_MAX_TOKENS", None)
|
||||
monkeypatch.setattr(hc_module, "BACKGROUND_HEALTH_CHECK_MAX_TOKENS_REASONING", None)
|
||||
|
||||
Reference in New Issue
Block a user