def test_prepare_chat_with_tools_tool_required():
    """Test that tool_required is correctly passed to the API request when True."""
    llm = AzureAICompletionsModel(
        endpoint="https://my-endpoint.inference.ai.azure.com",
        credential="my-api-key",
    )

    # Test with tool_required=True
    result = llm._prepare_chat_with_tools(tools=[search_tool], tool_required=True)

    assert result["tool_choice"] == ChatCompletionsToolChoicePreset.REQUIRED
    assert len(result["tools"]) == 1
    assert result["tools"][0]["function"]["name"] == "search_tool"
Test that tool_required is correctly passed to the API request when True.
llama-index-integrations/llms/llama-index-llms-azure-inference/tests/test_llms_azure_inference.py