mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(azure): let the caller's api-version win over the deployment's on passthrough relays
This commit is contained in:
parent
6f99917b33
commit
c698ddeacb
2 changed files with 10 additions and 4 deletions
|
|
@ -61,11 +61,11 @@ class AzurePassthroughConfig(BasePassthroughConfig):
|
|||
routed_endpoint: Final = replace_path_segment(endpoint, model_group, model) if model_group else endpoint
|
||||
native_endpoint: Final = strip_leading_model_segment(routed_endpoint, (model,))
|
||||
|
||||
caller_api_version: Final = request_query_params.get("api-version") if request_query_params else None
|
||||
complete_url: Final = BaseAzureLLM._get_base_azure_url(
|
||||
api_base=base_target_url,
|
||||
litellm_params=litellm_params,
|
||||
litellm_params={**litellm_params, "api_version": caller_api_version or litellm_params.get("api_version")},
|
||||
route=native_endpoint,
|
||||
default_api_version=request_query_params.get("api-version") if request_query_params else None,
|
||||
)
|
||||
return (
|
||||
httpx.URL(complete_url),
|
||||
|
|
|
|||
|
|
@ -207,18 +207,24 @@ def _complete_url(request_query_params: dict, litellm_params: dict) -> httpx.URL
|
|||
return url
|
||||
|
||||
|
||||
def test_azure_passthrough_url_falls_back_to_the_callers_api_version():
|
||||
def test_azure_passthrough_url_forwards_the_callers_api_version():
|
||||
url = _complete_url(request_query_params={"api-version": "2025-04-01-preview"}, litellm_params={})
|
||||
|
||||
assert url.path == "/openai/deployments/gpt-4.1-mini/chat/completions"
|
||||
assert url.params["api-version"] == "2025-04-01-preview"
|
||||
|
||||
|
||||
def test_azure_passthrough_url_prefers_the_deployments_api_version():
|
||||
def test_azure_passthrough_url_prefers_the_callers_api_version_over_the_deployments():
|
||||
url = _complete_url(
|
||||
request_query_params={"api-version": "2025-04-01-preview"}, litellm_params={"api_version": "2024-10-21"}
|
||||
)
|
||||
|
||||
assert url.params["api-version"] == "2025-04-01-preview"
|
||||
|
||||
|
||||
def test_azure_passthrough_url_fills_in_the_deployments_api_version_when_the_caller_sends_none():
|
||||
url = _complete_url(request_query_params={}, litellm_params={"api_version": "2024-10-21"})
|
||||
|
||||
assert url.params["api-version"] == "2024-10-21"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue