Class: RubyLLM::Modes::Decision

Inherits:
Data
  • Object
show all
Defined in:
lib/ruby_llm/modes/decision.rb

Overview

What the classifier said, untouched.

mode_name: String or nil confidence: Float 0..1, or nil for "not scored" reason: String or nil probabilities: { name => Float } or nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode_name: nil, confidence: nil, reason: nil, probabilities: nil) ⇒ Decision

Returns a new instance of Decision.



12
13
14
# File 'lib/ruby_llm/modes/decision.rb', line 12

def initialize(mode_name: nil, confidence: nil, reason: nil, probabilities: nil)
  super
end

Instance Attribute Details

#confidence ⇒ Object (readonly)

Returns the value of attribute confidence

Returns:

  • (Object) —

    the current value of confidence



11
12
13
# File 'lib/ruby_llm/modes/decision.rb', line 11

def confidence
  @confidence
end

#mode_name ⇒ Object (readonly)

Returns the value of attribute mode_name

Returns:

  • (Object) —

    the current value of mode_name



11
12
13
# File 'lib/ruby_llm/modes/decision.rb', line 11

def mode_name
  @mode_name
end

#probabilities ⇒ Object (readonly)

Returns the value of attribute probabilities

Returns:

  • (Object) —

    the current value of probabilities



11
12
13
# File 'lib/ruby_llm/modes/decision.rb', line 11

def probabilities
  @probabilities
end

#reason ⇒ Object (readonly)

Returns the value of attribute reason

Returns:

  • (Object) —

    the current value of reason



11
12
13
# File 'lib/ruby_llm/modes/decision.rb', line 11

def reason
  @reason
end

Instance Method Details

#to_h ⇒ Object

The fields with string keys, for logs and serialisation. "probabilities" is present only when the classifier set them.



18
19
20
21
# File 'lib/ruby_llm/modes/decision.rb', line 18

def to_h
  hash = super.transform_keys(&:to_s)
  probabilities ? hash.merge("probabilities" => probabilities.transform_keys(&:to_s)) : hash.except("probabilities")
end