From 1c67b7e1daf28a9d9afc24d647adfb35c71d322b Mon Sep 17 00:00:00 2001 From: AlexsanderHamir Date: Thu, 20 Nov 2025 17:48:40 -0800 Subject: [PATCH] fix: place hardcoded value on constants.py --- litellm/constants.py | 1 + litellm/proxy/proxy_server.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/constants.py b/litellm/constants.py index 3f763cad926..fc26e1cf817 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -246,6 +246,7 @@ TOGETHER_AI_EMBEDDING_350_M = int(os.getenv("TOGETHER_AI_EMBEDDING_350_M", 350)) QDRANT_SCALAR_QUANTILE = float(os.getenv("QDRANT_SCALAR_QUANTILE", 0.99)) QDRANT_VECTOR_SIZE = int(os.getenv("QDRANT_VECTOR_SIZE", 1536)) CACHED_STREAMING_CHUNK_DELAY = float(os.getenv("CACHED_STREAMING_CHUNK_DELAY", 0.02)) +AUDIO_SPEECH_CHUNK_SIZE = 8192 # chunk_size for audio speech streaming. Balance between latency and memory usage MAX_SIZE_PER_ITEM_IN_MEMORY_CACHE_IN_KB = int( os.getenv("MAX_SIZE_PER_ITEM_IN_MEMORY_CACHE_IN_KB", 512) ) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index da592c90720..47c30e9ce84 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -32,6 +32,7 @@ from litellm.constants import ( AIOHTTP_CONNECTOR_LIMIT, AIOHTTP_KEEPALIVE_TIMEOUT, AIOHTTP_TTL_DNS_CACHE, + AUDIO_SPEECH_CHUNK_SIZE, BASE_MCP_ROUTE, DEFAULT_MAX_RECURSE_DEPTH, DEFAULT_SHARED_HEALTH_CHECK_LOCK_TTL, @@ -5240,7 +5241,7 @@ async def _audio_speech_chunk_generator( # too small: latency is high # too large: latency is low, but memory usage is high # 8192 is a good compromise - _generator = await _response.aiter_bytes(chunk_size=8192) + _generator = await _response.aiter_bytes(chunk_size=AUDIO_SPEECH_CHUNK_SIZE) async for chunk in _generator: yield chunk