Class: Legion::Extensions::Agentic::Memory::Nostalgia::Helpers::NostalgicMemory
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Nostalgia::Helpers::NostalgicMemory
- Defined in:
- lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#original_valence ⇒ Object
readonly
Returns the value of attribute original_valence.
-
#temporal_distance ⇒ Object
readonly
Returns the value of attribute temporal_distance.
Instance Method Summary collapse
- #age! ⇒ Object
- #bittersweet? ⇒ Boolean
- #cool!(amount = Constants::WARMTH_DECAY) ⇒ Object
- #current_valence ⇒ Object
-
#initialize(content:, domain: :unknown, warmth: Constants::DEFAULT_WARMTH, original_valence: 0.5) ⇒ NostalgicMemory
constructor
A new instance of NostalgicMemory.
- #rosy? ⇒ Boolean
- #to_h ⇒ Object
- #warm!(amount = Constants::WARMTH_GROWTH) ⇒ Object
- #warmth ⇒ Object
- #warmth_label ⇒ Object
Constructor Details
#initialize(content:, domain: :unknown, warmth: Constants::DEFAULT_WARMTH, original_valence: 0.5) ⇒ NostalgicMemory
Returns a new instance of NostalgicMemory.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 14 def initialize(content:, domain: :unknown, warmth: Constants::DEFAULT_WARMTH, original_valence: 0.5) @id = ::SecureRandom.uuid @content = content @domain = normalize_domain(domain) @warmth = warmth.clamp(0.0, Constants::WARMTH_CEILING) @original_valence = original_valence.clamp(0.0, 1.0) @current_valence = @original_valence @temporal_distance = 0 @created_at = Time.now.utc end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 12 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 12 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 12 def id @id end |
#original_valence ⇒ Object (readonly)
Returns the value of attribute original_valence.
12 13 14 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 12 def original_valence @original_valence end |
#temporal_distance ⇒ Object (readonly)
Returns the value of attribute temporal_distance.
12 13 14 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 12 def temporal_distance @temporal_distance end |
Instance Method Details
#age! ⇒ Object
34 35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 34 def age! @temporal_distance += 1 growth = Constants::WARMTH_GROWTH * temporal_distance_factor @warmth = (@warmth + growth).clamp(0.0, Constants::WARMTH_CEILING) self end |
#bittersweet? ⇒ Boolean
57 58 59 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 57 def bittersweet? warmth >= Constants::BITTERSWEET_THRESHOLD && @original_valence < Constants::BITTERSWEET_THRESHOLD end |
#cool!(amount = Constants::WARMTH_DECAY) ⇒ Object
48 49 50 51 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 48 def cool!(amount = Constants::WARMTH_DECAY) @warmth = (@warmth - amount.clamp(0.0, 1.0)).clamp(0.0, Constants::WARMTH_CEILING) self end |
#current_valence ⇒ Object
30 31 32 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 30 def current_valence @current_valence.round(10) end |
#rosy? ⇒ Boolean
53 54 55 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 53 def rosy? warmth > @original_valence end |
#to_h ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 65 def to_h { id: id, content: content, domain: domain, warmth: warmth, warmth_label: warmth_label, temporal_distance: temporal_distance, original_valence: @original_valence, current_valence: current_valence, rosy: rosy?, bittersweet: bittersweet?, created_at: created_at } end |
#warm!(amount = Constants::WARMTH_GROWTH) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 41 def warm!(amount = Constants::WARMTH_GROWTH) factor = 1.0 + (temporal_distance / 100.0) @warmth = (@warmth + (amount.clamp(0.0, 1.0) * factor)).clamp(0.0, Constants::WARMTH_CEILING) @current_valence = [@current_valence + (amount * 0.5), 1.0].min.round(10) self end |
#warmth ⇒ Object
26 27 28 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 26 def warmth @warmth.round(10) end |
#warmth_label ⇒ Object
61 62 63 |
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb', line 61 def warmth_label Constants.label_for(Constants::WARMTH_LABELS, warmth) end |