Package com.google.genai.types
Class SafetySetting
-
- All Implemented Interfaces:
public abstract class SafetySetting extends JsonSerializable
A safety setting that affects the safety-blocking behavior. A SafetySetting consists of a harm category and a threshold for that category.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract classSafetySetting.BuilderBuilder for SafetySetting.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description SafetySetting()
-
Method Summary
Modifier and Type Method Description abstract Optional<HarmCategory>category()Required. abstract Optional<HarmBlockMethod>method()Optional. abstract Optional<HarmBlockThreshold>threshold()Required. static SafetySetting.Builderbuilder()Instantiates a builder for SafetySetting. abstract SafetySetting.BuildertoBuilder()Creates a builder with the same values as this instance. static SafetySettingfromJson(String jsonString)Deserializes a JSON string to a SafetySetting object. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
category
abstract Optional<HarmCategory> category()
Required. The harm category to be blocked.
-
method
abstract Optional<HarmBlockMethod> 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.
-
threshold
abstract Optional<HarmBlockThreshold> threshold()
Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.
-
builder
static SafetySetting.Builder builder()
Instantiates a builder for SafetySetting.
-
toBuilder
abstract SafetySetting.Builder toBuilder()
Creates a builder with the same values as this instance.
-
fromJson
static SafetySetting fromJson(String jsonString)
Deserializes a JSON string to a SafetySetting object.
-
-
-
-