def to_easy_safety_dict()

in google/generativeai/types/palm_safety_types.py [0:0]


def to_easy_safety_dict(settings: SafetySettingOptions) -> EasySafetySettingDict:
    if settings is None:
        return {}
    elif isinstance(settings, Mapping):
        return {to_harm_category(key): to_block_threshold(value) for key, value in settings.items()}
    else:  # Iterable
        return {
            to_harm_category(d["category"]): to_block_threshold(d["threshold"]) for d in settings
        }