mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
Merge 44838201ce into 9dda4d895f
This commit is contained in:
commit
58da8a8b53
2 changed files with 17 additions and 1 deletions
|
|
@ -1796,7 +1796,11 @@ def _get_httpx_client(params: dict | None = None) -> HTTPHandler:
|
|||
|
||||
if params is not None:
|
||||
# Filter out params that are only used for cache key, not for HTTPHandler.__init__
|
||||
handler_params: Final = {k: v for k, v in params.items() if k != "disable_aiohttp_transport"}
|
||||
configured_timeout: Final = params.get("timeout")
|
||||
handler_params: Final = {
|
||||
**{k: v for k, v in params.items() if k not in ("disable_aiohttp_transport", "timeout")},
|
||||
"timeout": configured_timeout if configured_timeout is not None else _default_cached_client_timeout(),
|
||||
}
|
||||
_new_client = HTTPHandler(**handler_params)
|
||||
else:
|
||||
_new_client = HTTPHandler(timeout=_default_cached_client_timeout())
|
||||
|
|
|
|||
|
|
@ -741,6 +741,18 @@ class TestDefaultCachedClientTimeoutHonorsRequestTimeout:
|
|||
client = get_async_httpx_client(llm_provider=LlmProviders.BEDROCK)
|
||||
assert client.timeout.read == 300.0
|
||||
|
||||
def test_cached_sync_client_with_none_timeout_uses_explicit_request_timeout(self, monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.caching.llm_caching_handler import LLMClientCache
|
||||
|
||||
monkeypatch.setattr(litellm, "request_timeout", 300)
|
||||
monkeypatch.setattr(litellm, "request_timeout_explicitly_set", True)
|
||||
monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache())
|
||||
|
||||
client = _get_httpx_client(params={"timeout": None})
|
||||
request = client.client.build_request("GET", "https://example.com")
|
||||
|
||||
assert request.extensions["timeout"]["read"] == 300.0
|
||||
|
||||
|
||||
async def _read_http_request(reader: asyncio.StreamReader) -> None:
|
||||
raw = b""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue