mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-25 05:54:53 +00:00
fix(azure-anthropic): type transformed request body
This commit is contained in:
parent
1e15ff50ad
commit
eb979f7fb3
2 changed files with 17 additions and 15 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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={
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue