def format_quantity(quantity: float, precision: int = 2) -> str:
    """Format a quantity into a human-readable string. This will use SI prefixes.
    Implementation details are largely copied from [millify](https://github.com/azaitsev/millify).

    Args:
        quantity (float): The quantity to format.
        precision (int, optional): The precision to use. Defaults to 2.

    Returns:
        str: The formatted quantity.
    """
    units = ["", "k", "M", "B", "T", "P", "E", "Z", "Y"]
    unit_idx = max(
        0,
        min(
            len(units) - 1,
            int(
                math.floor(
                    0 if quantity == 0 else math.log10(abs(quantity)) / 3
                )
            ),
        ),
    )
    result = "{:.{precision}f}".format(
        quantity / 10 ** (3 * unit_idx), precision=precision
    )
    return f"{result}{units[unit_idx]}"
Format a quantity into a human-readable string. This will use SI prefixes.
    Implementation details are largely copied from [millify](https://github.com/azaitsev/millify).

    Args:
        quantity (float): The quantity to format.
        precision (int, optional): The precision to use. Defaults to 2.

    Returns:
        str: The formatted quantity.
    
src/core/trulens/core/utils/text.py