diff --git a/litellm/llms/azure_ai/anthropic/transformation.py b/litellm/llms/azure_ai/anthropic/transformation.py index 0b588b6cc52..a25559ecef3 100644 --- a/litellm/llms/azure_ai/anthropic/transformation.py +++ b/litellm/llms/azure_ai/anthropic/transformation.py @@ -115,22 +115,24 @@ class AzureAnthropicConfig(AnthropicConfig): self, model: str, messages: list[AllMessageValues], - optional_params: dict, - litellm_params: dict, - headers: dict, - ) -> dict: + optional_params: dict[str, object], + litellm_params: dict[str, object], + headers: dict[str, object], + ) -> dict[str, object]: """ Transform request using parent AnthropicConfig, then remove unsupported params. Azure Anthropic doesn't support extra_body, max_retries, or stream_options parameters. """ _promote_extra_body_to_optional_params(optional_params) - data: Final = super().transform_request( - model=model, - messages=messages, - optional_params=optional_params, - litellm_params=litellm_params, - headers=headers, - ) + data: Final[dict[str, object]] = { + **super().transform_request( + model=model, + messages=messages, + optional_params=optional_params, + litellm_params=litellm_params, + headers=headers, + ) + } return {key: value for key, value in data.items() if key not in _AZURE_ANTHROPIC_NON_BODY_PARAMS} diff --git a/tests/unit/test_azure_ad_token_credential_resolution.py b/tests/unit/test_azure_ad_token_credential_resolution.py index 07106582d0e..c0469842c0f 100644 --- a/tests/unit/test_azure_ad_token_credential_resolution.py +++ b/tests/unit/test_azure_ad_token_credential_resolution.py @@ -214,7 +214,7 @@ class TestRouterCredentialResolutionS3OutputBucket: def test_azure_anthropic_request_body_does_not_include_azure_credentials() -> None: from litellm.llms.azure_ai.anthropic.transformation import AzureAnthropicConfig - credential_params: Final = { + credential_params: Final[dict[str, str]] = { "api_key": "test-api-key", "azure_ad_token": "test-access-token", "azure_ad_token_provider": "test-token-provider", @@ -225,13 +225,13 @@ def test_azure_anthropic_request_body_does_not_include_azure_credentials() -> No "azure_username": "test-username", "azure_password": "test-password", } - output_config: Final = {"format": {"type": "json_object"}} - extra_body_params: Final = { + output_config: Final[dict[str, dict[str, str]]] = {"format": {"type": "json_object"}} + extra_body_params: Final[dict[str, str]] = { key: value for key, value in credential_params.items() if key not in {"api_key", "azure_ad_token"} } - body: Final = AzureAnthropicConfig().transform_request( + body: Final[dict[str, object]] = AzureAnthropicConfig().transform_request( model="claude-3-5-sonnet-20241022", messages=[{"role": "user", "content": "hello"}], optional_params={