def maybe_decode_sse_data(data: bytes) -> Union[dict, None]:
    """
    Decode data from the streaming response.
    Checks whether the incoming data is an actual
    SSE data message.

    Args:
        data (bytes): The incoming data.

    Returns:
        Union[dict, None]: The decoded data or None.

    """
    if data and data.startswith(b"data: "):
        data = data.decode("utf-8").strip("data: ")
        try:
            return json.loads(data)
        except json.JSONDecodeError:
            return None
    else:
        return None

    Decode data from the streaming response.
    Checks whether the incoming data is an actual
    SSE data message.

    Args:
        data (bytes): The incoming data.

    Returns:
        Union[dict, None]: The decoded data or None.

    
llama-index-integrations/llms/llama-index-llms-deepinfra/llama_index/llms/deepinfra/utils.py