FirebaseVertexAI Framework Reference

SafetySetting

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SafetySetting : Sendable
extension SafetySetting: Encodable

A type used to specify a threshold for harmful content, beyond which the model will return a fallback response instead of generated content.

See safety settings for Gemini models for more details.

  • Block at and beyond a specified HarmProbability.

    Declaration

    Swift

    public struct HarmBlockThreshold : EncodableProtoEnum, Sendable
    extension SafetySetting.HarmBlockThreshold: Encodable
  • The method of computing whether the HarmBlockThreshold has been exceeded.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
    public struct HarmBlockMethod : EncodableProtoEnum, Sendable
  • The category this safety setting should be applied to.

    Declaration

    Swift

    public let harmCategory: HarmCategory
  • The threshold describing what content should be blocked.

    Declaration

    Swift

    public let threshold: HarmBlockThreshold
  • The method of computing whether the threshold has been exceeded.

    Declaration

    Swift

    public let method: HarmBlockMethod?
  • Initializes a new safety setting with the given category and threshold.

    Declaration

    Swift

    public init(harmCategory: HarmCategory, threshold: HarmBlockThreshold,
                method: HarmBlockMethod? = nil)

    Parameters

    harmCategory

    The category this safety setting should be applied to.

    threshold

    The threshold describing what content should be blocked.

    method

    The method of computing whether the threshold has been exceeded; if not specified, the default method is severity for most models. See harm block methods in the Google Cloud documentation for more details. > Note: For models older than gemini-1.5-flash and gemini-1.5-pro, the default method > is probability.