Class: Geminize::Models::SafetySetting

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(category, threshold) ⇒ SafetySetting

Initialize a new safety setting

Parameters:

  • category (String)

    The harm category this setting applies to

  • threshold (String)

    The threshold level for filtering

Raises:



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

#categoryString (readonly)

Returns The harm category this setting applies to.

Returns:

  • (String)

    The harm category this setting applies to



24
25
26
# File 'lib/geminize/models/safety_setting.rb', line 24

def category
  @category
end

#thresholdString (readonly)

Returns The threshold level for filtering.

Returns:

  • (String)

    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_hHash

Alias for to_hash

Returns:

  • (Hash)

    The safety setting as a hash



59
60
61
# File 'lib/geminize/models/safety_setting.rb', line 59

def to_h
  to_hash
end

#to_hashHash

Convert the safety setting to a hash for API requests

Returns:

  • (Hash)

    The safety setting as a hash



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

Returns:

  • (Boolean)

    true if validation passes

Raises:



42
43
44
45
46
# File 'lib/geminize/models/safety_setting.rb', line 42

def validate!
  validate_category!
  validate_threshold!
  true
end