From e2d0fd9eacdeadf46c0e18057e5f51ea1f28eb49 Mon Sep 17 00:00:00 2001 From: RoomWithOutRoof <166608075+Jah-yee@users.noreply.github.com> Date: Sun, 26 Apr 2026 01:45:01 +0800 Subject: [PATCH] fix: remove duplicate MAX_SIZE + add Cloudflare response_text support (#26385) - Remove duplicate MAX_SIZE_PER_ITEM_IN_MEMORY_CACHE_IN_KB definition (kept the one with default 1024, removed the one with default 512) - Add fallback from 'response' to 'response_text' key in Cloudflare Workers AI transformation for newer Nemotron models Co-authored-by: yuneng-jiang Co-authored-by: Jah-yee <110645028+Jah-yee@users.noreply.github.com> --- litellm/constants.py | 3 --- litellm/llms/cloudflare/chat/transformation.py | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/litellm/constants.py b/litellm/constants.py index 012599ab6ab..385e3723bee 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -409,9 +409,6 @@ CACHED_STREAMING_CHUNK_DELAY = float(os.getenv("CACHED_STREAMING_CHUNK_DELAY", 0 AUDIO_SPEECH_CHUNK_SIZE = int( os.getenv("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) -) DEFAULT_MAX_TOKENS_FOR_TRITON = int(os.getenv("DEFAULT_MAX_TOKENS_FOR_TRITON", 2000)) #### Networking settings #### # Sentinel used when `REQUEST_TIMEOUT` is unset: `litellm.request_timeout` keeps this diff --git a/litellm/llms/cloudflare/chat/transformation.py b/litellm/llms/cloudflare/chat/transformation.py index 9e59782bf73..d0c2e86f708 100644 --- a/litellm/llms/cloudflare/chat/transformation.py +++ b/litellm/llms/cloudflare/chat/transformation.py @@ -147,9 +147,9 @@ class CloudflareChatConfig(BaseConfig): ) -> ModelResponse: completion_response = raw_response.json() - model_response.choices[0].message.content = completion_response["result"][ # type: ignore - "response" - ] + # Support both "response" and "response_text" keys (newer models like Nemotron use "response_text") + result = completion_response["result"] + model_response.choices[0].message.content = result.get("response") if result.get("response") is not None else result.get("response_text", "") # type: ignore prompt_tokens = litellm.utils.get_token_count(messages=messages, model=model) completion_tokens = len(