diff --git a/tests/llm_translation/test_azure_o_series.py b/tests/llm_translation/test_azure_o_series.py index 13ba4169ceb..ce9a32f8608 100644 --- a/tests/llm_translation/test_azure_o_series.py +++ b/tests/llm_translation/test_azure_o_series.py @@ -170,3 +170,54 @@ def test_openai_o_series_max_retries_0(mock_get_openai_client): mock_get_openai_client.assert_called_once() assert mock_get_openai_client.call_args.kwargs["max_retries"] == 0 + + +@pytest.mark.asyncio +async def test_azure_o1_series_response_format_extra_params(): + """ + Tool calling should work for all azure o_series models. + """ + litellm._turn_on_debug() + + from openai import AsyncAzureOpenAI + + litellm.set_verbose = True + + client = AsyncAzureOpenAI( + api_key="fake-api-key", + base_url="https://openai-prod-test.openai.azure.com/openai/deployments/o1/chat/completions?api-version=2025-01-01-preview", + api_version="2025-01-01-preview" + ) + + tools = [{'type': 'function', 'function': {'name': 'get_current_time', 'description': 'Get the current time in a given location.', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city name, e.g. San Francisco'}}, 'required': ['location']}}}] + response_format = {'type': 'json_object'} + tool_choice = "auto" + with patch.object( + client.chat.completions.with_raw_response, "create" + ) as mock_client: + try: + await litellm.acompletion( + client=client, + model="azure/o_series/", + api_key="xxxxx", + api_base="https://openai-prod-test.openai.azure.com/openai/deployments/o1/chat/completions?api-version=2025-01-01-preview", + api_version="2024-12-01-preview", + messages=[{"role": "user", "content": "Hello! return a json object"}], + tools=tools, + response_format=response_format, + tool_choice=tool_choice + ) + except Exception as e: + print(f"Error: {e}") + + mock_client.assert_called_once() + request_body = mock_client.call_args.kwargs + + print("request_body: ", json.dumps(request_body, indent=4)) + assert request_body["tools"] == tools + assert request_body["response_format"] == response_format + assert request_body["tool_choice"] == tool_choice + + + +