mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-10 16:22:17 +00:00
fix: allow users to disable aiohttp transport
This commit is contained in:
+2
-1
@@ -303,7 +303,8 @@ priority_reservation: Optional[Dict[str, float]] = None
|
||||
|
||||
|
||||
######## Networking Settings ########
|
||||
use_aiohttp_transport: bool = True
|
||||
use_aiohttp_transport: bool = True # Older variable, aiohttp is now the default. use disable_aiohttp_transport instead.
|
||||
disable_aiohttp_transport: bool = False # Set this to true to use httpx instead
|
||||
force_ipv4: bool = False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6.
|
||||
module_level_aclient = AsyncHTTPHandler(
|
||||
timeout=request_timeout, client_alias="module level aclient"
|
||||
|
||||
@@ -505,20 +505,30 @@ class AsyncHTTPHandler:
|
||||
@staticmethod
|
||||
def _should_use_aiohttp_transport() -> bool:
|
||||
"""
|
||||
This is feature flagged for now and is opt in as we roll out to all users.
|
||||
AiohttpTransport is the default transport for litellm.
|
||||
|
||||
Controlled by either
|
||||
- litellm.use_aiohttp_transport or os.getenv("USE_AIOHTTP_TRANSPORT") = "True"
|
||||
Httpx can be used by the following
|
||||
- litellm.disable_aiohttp_transport = True
|
||||
- os.getenv("DISABLE_AIOHTTP_TRANSPORT") = "True"
|
||||
"""
|
||||
import os
|
||||
|
||||
from litellm.secret_managers.main import str_to_bool
|
||||
|
||||
#########################################################
|
||||
# Check if user disabled aiohttp transport
|
||||
########################################################
|
||||
if (
|
||||
str_to_bool(os.getenv("USE_AIOHTTP_TRANSPORT", "False"))
|
||||
or litellm.use_aiohttp_transport
|
||||
litellm.disable_aiohttp_transport is True
|
||||
or str_to_bool(os.getenv("DISABLE_AIOHTTP_TRANSPORT", "False")) is True
|
||||
):
|
||||
verbose_logger.debug("Using AiohttpTransport...")
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
#########################################################
|
||||
# Default: Use AiohttpTransport
|
||||
########################################################
|
||||
verbose_logger.debug("Using AiohttpTransport...")
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _create_aiohttp_transport(
|
||||
|
||||
Reference in New Issue
Block a user