Class: Legion::Extensions::Agentic::Attention::Surprise::Helpers::SurpriseEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain:, predicted:, actual:, magnitude:, valence:, orienting: false) ⇒ SurpriseEvent

Returns a new instance of SurpriseEvent.



14
15
16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 14

def initialize(domain:, predicted:, actual:, magnitude:, valence:, orienting: false)
  @id        = SecureRandom.uuid
  @domain    = domain
  @predicted = predicted
  @actual    = actual
  @magnitude = magnitude.clamp(0.0, 1.0)
  @valence   = valence
  @orienting = orienting
  @timestamp = Time.now.utc
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def actual
  @actual
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def id
  @id
end

#magnitudeObject (readonly)

Returns the value of attribute magnitude.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def magnitude
  @magnitude
end

#orientingObject (readonly)

Returns the value of attribute orienting.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def orienting
  @orienting
end

#predictedObject (readonly)

Returns the value of attribute predicted.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def predicted
  @predicted
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def timestamp
  @timestamp
end

#valenceObject (readonly)

Returns the value of attribute valence.



12
13
14
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 12

def valence
  @valence
end

Instance Method Details

#to_hObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/legion/extensions/agentic/attention/surprise/helpers/surprise_event.rb', line 25

def to_h
  {
    id:        @id,
    domain:    @domain,
    predicted: @predicted,
    actual:    @actual,
    magnitude: @magnitude.round(4),
    valence:   @valence,
    orienting: @orienting,
    timestamp: @timestamp
  }
end