Class: Legion::Extensions::Agentic::Memory::Episodic::Helpers::EpisodicBinding
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Episodic::Helpers::EpisodicBinding
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb
Constant Summary
Constants included from Constants
Constants::ATTENTION_BOOST, Constants::BINDING_DECAY, Constants::BINDING_STRENGTH_FLOOR, Constants::COHERENCE_LABELS, Constants::DEFAULT_BINDING_STRENGTH, Constants::EPISODE_TTL, Constants::INTEGRATION_THRESHOLD, Constants::MAX_BINDINGS_PER_EPISODE, Constants::MAX_EPISODES, Constants::MAX_HISTORY, Constants::MODALITIES, Constants::RECENTLY_ACCESSED_WINDOW, Constants::REHEARSAL_BOOST
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#modality ⇒ Object
readonly
Returns the value of attribute modality.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#strength ⇒ Object
readonly
Returns the value of attribute strength.
Instance Method Summary collapse
- #decay ⇒ Object
- #faded? ⇒ Boolean
-
#initialize(modality:, content:, source:, strength: DEFAULT_BINDING_STRENGTH) ⇒ EpisodicBinding
constructor
A new instance of EpisodicBinding.
- #integrated? ⇒ Boolean
- #strengthen(amount) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(modality:, content:, source:, strength: DEFAULT_BINDING_STRENGTH) ⇒ EpisodicBinding
Returns a new instance of EpisodicBinding.
16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 16 def initialize(modality:, content:, source:, strength: DEFAULT_BINDING_STRENGTH) raise ArgumentError, "invalid modality: #{modality}" unless MODALITIES.include?(modality.to_sym) @id = SecureRandom.uuid @modality = modality.to_sym @content = content @source = source.to_sym @strength = strength.to_f.clamp(0.0, 1.0) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 14 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 14 def id @id end |
#modality ⇒ Object (readonly)
Returns the value of attribute modality.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 14 def modality @modality end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 14 def source @source end |
#strength ⇒ Object (readonly)
Returns the value of attribute strength.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 14 def strength @strength end |
Instance Method Details
#decay ⇒ Object
26 27 28 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 26 def decay @strength = [@strength - BINDING_DECAY, 0.0].max end |
#faded? ⇒ Boolean
38 39 40 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 38 def faded? @strength <= BINDING_STRENGTH_FLOOR end |
#integrated? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 34 def integrated? @strength >= INTEGRATION_THRESHOLD end |
#strengthen(amount) ⇒ Object
30 31 32 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 30 def strengthen(amount) @strength = [@strength + amount.to_f, 1.0].min end |
#to_h ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 42 def to_h { id: @id, modality: @modality, content: @content, source: @source, strength: @strength } end |