mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
fix(azure): strip the gpt5_series/ selector from Responses deployment names
A deployment configured as azure/gpt5_series/<deployment> sent gpt5_series/<deployment> as the model of Azure Responses requests, which Azure rejects because no such deployment exists. Chat completions already strip the selector, so Responses now does the same.
This commit is contained in:
parent
4786dd861b
commit
99d54ff085
2 changed files with 19 additions and 1 deletions
|
|
@ -110,7 +110,8 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
return BaseAzureLLM.base_validate_azure_environment(headers=headers, litellm_params=litellm_params)
|
||||
|
||||
def get_stripped_model_name(self, model: str) -> str:
|
||||
return model.replace("responses/", "").replace("o_series/", "").replace("azure_ai/", "")
|
||||
stripped: Final = model.replace("responses/", "").replace("o_series/", "").replace("azure_ai/", "")
|
||||
return stripped.removeprefix(AzureOpenAIGPT5Config.GPT5_SERIES_ROUTE)
|
||||
|
||||
def _handle_reasoning_item(self, item: dict[str, Any]) -> Mapping[str, object]:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1297,6 +1297,23 @@ def test_azure_responses_sends_the_deployment_name_when_azure_ai_prefix_survives
|
|||
assert request["model"] == "gpt-5.4-nano"
|
||||
|
||||
|
||||
def test_gpt5_series_selector_is_not_sent_as_part_of_the_deployment_name(respx_mock: respx.MockRouter) -> None:
|
||||
route: Final = respx_mock.post(host="example-resource.openai.azure.com").mock(
|
||||
return_value=httpx.Response(200, json=_COMPLETED_RESPONSE)
|
||||
)
|
||||
|
||||
response: Final = litellm.responses(
|
||||
model="azure/gpt5_series/my-gpt-5-deployment",
|
||||
input="hi",
|
||||
api_base=_AZURE_RESOURCE,
|
||||
api_key="azure-test-key",
|
||||
)
|
||||
|
||||
assert response.output[0].content[0].text == "Done."
|
||||
assert route.call_count == 1
|
||||
assert json.loads(route.calls[0].request.content)["model"] == "my-gpt-5-deployment"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_azure_responses_api_status_error():
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue