Class: Geminize::Models::SafetySetting
- Inherits:
-
Object
- Object
- Geminize::Models::SafetySetting
- Defined in:
- lib/geminize/models/safety_setting.rb
Overview
Represents a safety setting for content filtering in Gemini API
Constant Summary collapse
- HARM_CATEGORIES =
Valid harm categories for safety settings
[ "HARM_CATEGORY_HARASSMENT", "HARM_CATEGORY_HATE_SPEECH", "HARM_CATEGORY_SEXUALLY_EXPLICIT", "HARM_CATEGORY_DANGEROUS_CONTENT" ].freeze
- THRESHOLD_LEVELS =
Valid threshold levels for safety settings
[ "BLOCK_NONE", "BLOCK_LOW_AND_ABOVE", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_ONLY_HIGH" ].freeze
Instance Attribute Summary collapse
-
#category ⇒ String
readonly
The harm category this setting applies to.
-
#threshold ⇒ String
readonly
The threshold level for filtering.
Instance Method Summary collapse
-
#initialize(category, threshold) ⇒ SafetySetting
constructor
Initialize a new safety setting.
-
#to_h ⇒ Hash
Alias for to_hash.
-
#to_hash ⇒ Hash
Convert the safety setting to a hash for API requests.
-
#validate! ⇒ Boolean
Validate the safety setting.
Constructor Details
#initialize(category, threshold) ⇒ SafetySetting
Initialize a new safety setting
33 34 35 36 37 |
# File 'lib/geminize/models/safety_setting.rb', line 33 def initialize(category, threshold) @category = category @threshold = threshold validate! end |
Instance Attribute Details
#category ⇒ String (readonly)
Returns The harm category this setting applies to.
24 25 26 |
# File 'lib/geminize/models/safety_setting.rb', line 24 def category @category end |
#threshold ⇒ String (readonly)
Returns The threshold level for filtering.
27 28 29 |
# File 'lib/geminize/models/safety_setting.rb', line 27 def threshold @threshold end |
Instance Method Details
#to_h ⇒ Hash
Alias for to_hash
59 60 61 |
# File 'lib/geminize/models/safety_setting.rb', line 59 def to_h to_hash end |
#to_hash ⇒ Hash
Convert the safety setting to a hash for API requests
50 51 52 53 54 55 |
# File 'lib/geminize/models/safety_setting.rb', line 50 def to_hash { category: @category, threshold: @threshold } end |
#validate! ⇒ Boolean
Validate the safety setting
42 43 44 45 46 |
# File 'lib/geminize/models/safety_setting.rb', line 42 def validate! validate_category! validate_threshold! true end |