from typing import Set


def filter_fields(response, fields: Set[str]):
    """Filter response fields.

    Args:
        response (dict): Response as a dictionary.
        fields (set): Set of fields to filter on.

    Returns:
        dict: Filtered response.
    """
    if fields is None:
        return response
    return {k: response[k] for k in response.keys() & fields}