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): keep new helpers within the type discipline budget
Devin AI1d40202a4e88
diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.pyindex d5b1cbb7274..17ebde83eee 100644--- a/litellm/litellm_core_utils/prompt_templates/common_utils.py+++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py@@ -1564,7 +1564,9 @@ def strip_litellm_internal_message_fields(message: AllMessageValues) -> AllMessareturn messagereturn cast( # cast-ok: same TypedDict minus internal keysAllMessageValues,- {key: value for key, value in message.items() if key not in LITELLM_INTERNAL_MESSAGE_FIELDS},+ { # mutable-ok: provider transforms mutate message dicts in place downstream+ key: value for key, value in message.items() if key not in LITELLM_INTERNAL_MESSAGE_FIELDS+ },)diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.pyindex 4f61a39f692..420c357ab87 100644--- a/litellm/llms/databricks/chat/transformation.py+++ b/litellm/llms/databricks/chat/transformation.py@@ -3,7 +3,7 @@ Translates from OpenAI's `/v1/chat/completions` to Databricks' `/chat/completion"""import os-from collections.abc import AsyncIterator, Coroutine, Iterator+from collections.abc import AsyncIterator, Coroutine, Iterator, Mappingfrom typing import TYPE_CHECKING, Any, Final, Literal, cast, overloadimport httpx@@ -56,7 +56,7 @@ from ...openai_like.chat.transformation import OpenAILikeChatConfigfrom ..common_utils import DatabricksBase, DatabricksException-def _is_bare_assistant_message(message_dict: dict[str, Any]) -> bool:+def _is_bare_assistant_message(message_dict: Mapping[str, object]) -> bool:"""Databricks rejects assistant messages with neither content nor tool calls, e.g. a replayedthinking-only turn once its `thinking_blocks` are stripped."""return message_dict.get("role") == "assistant" and not any(@@ -442,7 +442,7 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig):if "cache_control" in _message and isinstance(_message.get("content"), str):_message = self._move_cache_control_into_string_content_block(_message)_sanitize_empty_content(cast(dict[str, Any], _message))- if _is_bare_assistant_message(cast(dict[str, Any], _message)):+ if _is_bare_assistant_message(_message):continuenew_messages.append(_message)