The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix databricks streaming test
Ishaan Jaff51da6ab64e27
diff --git a/litellm/litellm_core_utils/streaming_utils.py b/litellm/litellm_core_utils/streaming_utils.pynew file mode 100644index 00000000000..ca8d58e9f5e--- /dev/null+++ b/litellm/litellm_core_utils/streaming_utils.py@@ -0,0 +1,16 @@+from litellm.types.utils import GenericStreamingChunk as GChunk+++def generic_chunk_has_all_required_fields(chunk: dict) -> bool:+ """+ Checks if the provided chunk dictionary contains all required fields for GenericStreamingChunk.++ :param chunk: The dictionary to check.+ :return: True if all required fields are present, False otherwise.+ """+ _all_fields = GChunk.__annotations__++ # this is an optional field in GenericStreamingChunk, it's not required to be present+ _all_fields.pop("provider_specific_fields", None)++ return all(key in chunk for key in _all_fields)diff --git a/litellm/utils.py b/litellm/utils.pyindex f89a4a295a4..3934172c12b 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -9565,12 +9565,15 @@ class CustomStreamWrapper:try:# return this for all modelscompletion_obj = {"content": ""}+ from litellm.litellm_core_utils.streaming_utils import (+ generic_chunk_has_all_required_fields,+ )from litellm.types.utils import GenericStreamingChunk as GChunkif (isinstance(chunk, dict)- and all(- key in chunk for key in GChunk.__annotations__+ and generic_chunk_has_all_required_fields(+ chunk=chunk) # check if chunk is a generic streaming chunk) or (self.custom_llm_provider