Class SafetySetting
A safety setting that affects the safety-blocking behavior. A SafetySetting consists of a harm category and a threshold for that category.
public record SafetySetting : IEquatable<SafetySetting>
- Inheritance
-
SafetySetting
- Implements
- Inherited Members
Properties
Category
The harm category to be blocked.
[JsonPropertyName("category")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmCategory? Category { get; set; }
Property Value
Method
Optional. The method for blocking content. If not specified, the default behavior is to use the probability score. This field is not supported in Gemini API.
[JsonPropertyName("method")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmBlockMethod? Method { get; set; }
Property Value
Threshold
The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.
[JsonPropertyName("threshold")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HarmBlockThreshold? Threshold { get; set; }
Property Value
Methods
FromJson(string, JsonSerializerOptions?)
Deserializes a JSON string to a SafetySetting object.
public static SafetySetting? FromJson(string jsonString, JsonSerializerOptions? options = null)
Parameters
jsonStringstringThe JSON string to deserialize.
optionsJsonSerializerOptionsOptional JsonSerializerOptions.
Returns
- SafetySetting
The deserialized SafetySetting object, or null if deserialization fails.