SafetySetting
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct SafetySetting : Sendableextension SafetySetting: EncodableA 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, Sendableextension SafetySetting.HarmBlockThreshold: Encodable -
The method of computing whether the
HarmBlockThresholdhas 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
thresholdhas 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
harmCategoryThe category this safety setting should be applied to.
thresholdThe threshold describing what content should be blocked.
methodThe method of computing whether the threshold has been exceeded; if not specified, the default method is
severityfor most models. See harm block methods in the Google Cloud documentation for more details. > Note: For models older thangemini-1.5-flashandgemini-1.5-pro, the default method > isprobability.