This commit is contained in:
AxelRay 2026-09-19 19:26:08 +00:00 • committed by GitHub
commit 1d09fea25e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

@ -65,6 +65,12 @@ class OpenAILikeAnthropicMessagesConfig(AnthropicMessagesConfig):
def supports_cache_control_ttl(self) -> bool:
return self._cache_control_ttl
@staticmethod
def _translate_adaptive_effort_for_non_adaptive_model(
model: str, optional_params: dict[str, Any], max_tokens: int | None, custom_llm_provider: str
) -> None:
"""Keep native Anthropic adaptive fields intact for opted-in deployments."""
def transform_anthropic_messages_request(
self,
model: str,

View file

@ -94,6 +94,23 @@ def test_request_stays_in_anthropic_shape(config):
assert openai_only_keys.isdisjoint(payload.keys())
def test_request_preserves_adaptive_thinking_and_effort(config):
payload = config.transform_anthropic_messages_request(
model="my-model",
messages=[{"role": "user", "content": "hi"}],
anthropic_messages_optional_request_params={
"max_tokens": 256,
"thinking": {"type": "adaptive"},
"output_config": {"effort": "high"},
},
litellm_params=GenericLiteLLMParams(),
headers={},
)
assert payload["thinking"] == {"type": "adaptive"}
assert payload["output_config"] == {"effort": "high"}
def test_request_requires_max_tokens(config):
with pytest.raises(AnthropicError, match="max_tokens is required"):
config.transform_anthropic_messages_request(