Class: Legion::Extensions::Agentic::Inference::Debugging::Helpers::Correction

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_id:, strategy:, description:) ⇒ Correction

Returns a new instance of Correction.



14
15
16
17
18
19
20
21
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 14

def initialize(error_id:, strategy:, description:)
  @id            = SecureRandom.uuid
  @error_id      = error_id
  @strategy      = strategy
  @description   = description
  @applied       = false
  @effectiveness = nil
end

Instance Attribute Details

#appliedObject (readonly)

Returns the value of attribute applied.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 12

def applied
  @applied
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 12

def description
  @description
end

#effectivenessObject (readonly)

Returns the value of attribute effectiveness.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 12

def effectiveness
  @effectiveness
end

#error_idObject (readonly)

Returns the value of attribute error_id.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 12

def error_id
  @error_id
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 12

def id
  @id
end

#strategyObject (readonly)

Returns the value of attribute strategy.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 12

def strategy
  @strategy
end

Instance Method Details

#apply!Object



23
24
25
26
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 23

def apply!
  @applied = true
  self
end

#effective?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 33

def effective?
  return false if @effectiveness.nil?

  @effectiveness >= 0.6
end

#measure_effectiveness!(score) ⇒ Object



28
29
30
31
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 28

def measure_effectiveness!(score)
  @effectiveness = score.clamp(0.0, 1.0).round(10)
  self
end

#to_hObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb', line 39

def to_h
  {
    id:            @id,
    error_id:      @error_id,
    strategy:      @strategy,
    description:   @description,
    applied:       @applied,
    effectiveness: @effectiveness,
    effective:     effective?
  }
end