refactor(databricks): drive anthropic-thinking routing via JSON flag.

This commit is contained in:
cohml 2026-07-10 12:37:59 -04:00 committed by Chris Hamill
parent d7b793c054
commit 2bff743f43
6 changed files with 37 additions and 9 deletions

View file

@ -273,15 +273,14 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig):
GPT-5/GPT-OSS accept `reasoning_effort` natively and need no
translation.
"""
model_lower = model.lower()
if "claude" in model_lower:
return True
# Match gemini-2-5 / gemini-2.5 only — not the broader 2.x range, which
# could catch hypothetical future 2.0/2.6/etc variants that may use a
# different reasoning contract.
if "gemini-2-5" in model_lower or "gemini-2.5" in model_lower:
return True
return False
from litellm.utils import _supports_factory
normalized = model.lower().replace(".", "-")
return _supports_factory(
model=normalized,
custom_llm_provider="databricks",
key="supports_anthropic_thinking_payload",
)
def convert_anthropic_tool_to_databricks_tool(
self, tool: Optional[AllAnthropicToolsValues]

View file

@ -12690,6 +12690,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-haiku-4-5": {
@ -12709,6 +12710,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4": {
@ -12728,6 +12730,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-1": {
@ -12747,6 +12750,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-5": {
@ -12766,6 +12770,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true,
"supports_output_config": true
},
@ -12786,6 +12791,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-1": {
@ -12805,6 +12811,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-5": {
@ -12824,6 +12831,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-flash": {
@ -12841,6 +12849,7 @@
"output_dbu_cost_per_token": 3.5714e-05,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-pro": {
@ -12858,6 +12867,7 @@
"output_dbu_cost_per_token": 0.000142857,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemma-3-12b": {

View file

@ -151,6 +151,7 @@ class ProviderSpecificModelInfo(TypedDict, total=False):
supports_max_reasoning_effort: Optional[bool]
supports_output_config: Optional[bool]
supports_image_size: Optional[bool]
supports_anthropic_thinking_payload: Optional[bool]
bedrock_output_config_effort_ceiling: Optional[Literal["low", "medium", "high", "max", "xhigh"]]
bedrock_converse_supports_strict_tools: Optional[bool]

View file

@ -5472,6 +5472,7 @@ def _get_model_info_helper(
supports_url_context=_model_info.get("supports_url_context", None),
supports_reasoning=_model_info.get("supports_reasoning", None),
supports_adaptive_thinking=_model_info.get("supports_adaptive_thinking", None),
supports_anthropic_thinking_payload=_model_info.get("supports_anthropic_thinking_payload", None),
supports_none_reasoning_effort=_model_info.get("supports_none_reasoning_effort", None),
supports_minimal_reasoning_effort=_model_info.get("supports_minimal_reasoning_effort", None),
supports_low_reasoning_effort=_model_info.get("supports_low_reasoning_effort", None),

View file

@ -12690,6 +12690,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-haiku-4-5": {
@ -12709,6 +12710,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4": {
@ -12728,6 +12730,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-1": {
@ -12747,6 +12750,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-5": {
@ -12766,6 +12770,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true,
"supports_output_config": true
},
@ -12786,6 +12791,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-1": {
@ -12805,6 +12811,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-5": {
@ -12824,6 +12831,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-flash": {
@ -12841,6 +12849,7 @@
"output_dbu_cost_per_token": 3.5714e-05,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-pro": {
@ -12858,6 +12867,7 @@
"output_dbu_cost_per_token": 0.000142857,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemma-3-12b": {

View file

@ -8,6 +8,7 @@ from fastapi.testclient import TestClient
sys.path.insert(0, os.path.abspath("../../../../..")) # Adds the parent directory to the system path
from unittest.mock import MagicMock, patch
import litellm
from litellm.constants import (
DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET,
DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET,
@ -20,6 +21,12 @@ from litellm.llms.databricks.chat.transformation import (
)
@pytest.fixture(autouse=True)
def _use_local_model_cost_map(monkeypatch):
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
def test_transform_choices():
config = DatabricksConfig()
databricks_choices = [