mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
fix(passthrough): read the stream flag by truthiness in the timeout resolver
This commit is contained in:
parent
d4ee62eb8c
commit
58beea2275
2 changed files with 16 additions and 2 deletions
|
|
@ -10,7 +10,6 @@ DEFAULT_PASS_THROUGH_REQUEST_TIMEOUT_SECONDS: Final = 600.0
|
|||
class _TimeoutFields(BaseModel):
|
||||
model_config = ConfigDict(frozen=True)
|
||||
|
||||
stream: bool = False
|
||||
stream_timeout: float | None = None
|
||||
timeout: float | None = None
|
||||
request_timeout: float | None = None
|
||||
|
|
@ -61,10 +60,11 @@ def resolve_llm_passthrough_timeout(
|
|||
kwargs stream_timeout -> litellm_params stream_timeout -> router_stream_timeout, then the
|
||||
non-streaming chain above.
|
||||
"""
|
||||
streaming: Final = bool((kwargs or {}).get("stream"))
|
||||
request: Final = _TimeoutFields.model_validate(kwargs or {})
|
||||
deployment: Final = _TimeoutFields.model_validate(litellm_params or {})
|
||||
stream_candidates: Final = (
|
||||
(request.stream_timeout, deployment.stream_timeout, router_stream_timeout) if request.stream else ()
|
||||
(request.stream_timeout, deployment.stream_timeout, router_stream_timeout) if streaming else ()
|
||||
)
|
||||
candidates: Final = (
|
||||
*stream_candidates,
|
||||
|
|
|
|||
|
|
@ -1175,6 +1175,20 @@ def test_resolve_llm_passthrough_timeout_stream_timeout_precedence():
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"stream, expected",
|
||||
[(None, 90.0), (0, 90.0), ("", 90.0), (1, 1800.0), ("yes", 1800.0)],
|
||||
)
|
||||
def test_resolve_llm_passthrough_timeout_reads_stream_by_truthiness(stream: object, expected: float):
|
||||
assert (
|
||||
resolve_llm_passthrough_timeout(
|
||||
kwargs={"stream": stream},
|
||||
litellm_params={"stream_timeout": 1800, "timeout": 90},
|
||||
)
|
||||
== expected
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pass_through_request_uses_resolved_timeout():
|
||||
with patch("litellm.proxy.proxy_server.proxy_logging_obj") as mock_proxy_logging:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue