Class: Legion::Extensions::Agentic::Memory::Echo::Helpers::Echo
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Echo::Helpers::Echo
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/memory/echo/helpers/echo.rb
Constant Summary
Constants included from Constants
Constants::CHAMBER_LABELS, Constants::DEFAULT_INTENSITY, Constants::ECHO_DECAY, Constants::ECHO_TYPES, Constants::EFFECT_LABELS, Constants::INTENSITY_LABELS, Constants::INTERFERENCE_THRESHOLD, Constants::MAX_ECHOES, Constants::MAX_INTERACTIONS, Constants::PRIMING_THRESHOLD, Constants::REINFORCEMENT, Constants::SILENT_THRESHOLD
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#decay_count ⇒ Object
readonly
Returns the value of attribute decay_count.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#echo_type ⇒ Object
readonly
Returns the value of attribute echo_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#intensity ⇒ Object
readonly
Returns the value of attribute intensity.
-
#original_intensity ⇒ Object
readonly
Returns the value of attribute original_intensity.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #decay! ⇒ Object
- #effect_label ⇒ Object
-
#initialize(content:, echo_type: :thought, domain: :general, intensity: DEFAULT_INTENSITY) ⇒ Echo
constructor
A new instance of Echo.
- #intensity_label ⇒ Object
- #interfering? ⇒ Boolean
- #persistence ⇒ Object
- #priming? ⇒ Boolean
- #reinforce!(amount = REINFORCEMENT) ⇒ Object
- #silent? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(content:, echo_type: :thought, domain: :general, intensity: DEFAULT_INTENSITY) ⇒ Echo
Returns a new instance of Echo.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 17 def initialize(content:, echo_type: :thought, domain: :general, intensity: DEFAULT_INTENSITY) @id = SecureRandom.uuid @content = content @echo_type = validate_type(echo_type) @domain = domain.to_sym @intensity = intensity.to_f.clamp(0.0, 1.0).round(10) @original_intensity = @intensity @decay_count = 0 @created_at = Time.now.utc end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def created_at @created_at end |
#decay_count ⇒ Object (readonly)
Returns the value of attribute decay_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def decay_count @decay_count end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def domain @domain end |
#echo_type ⇒ Object (readonly)
Returns the value of attribute echo_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def echo_type @echo_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def id @id end |
#intensity ⇒ Object (readonly)
Returns the value of attribute intensity.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def intensity @intensity end |
#original_intensity ⇒ Object (readonly)
Returns the value of attribute original_intensity.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 14 def original_intensity @original_intensity end |
Instance Method Details
#active? ⇒ Boolean
43 44 45 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 43 def active? @intensity > SILENT_THRESHOLD end |
#decay! ⇒ Object
28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 28 def decay! @decay_count += 1 @intensity = (@intensity - ECHO_DECAY).clamp(0.0, 1.0).round(10) self end |
#effect_label ⇒ Object
62 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 62 def effect_label = Constants.label_for(EFFECT_LABELS, @intensity) |
#intensity_label ⇒ Object
61 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 61 def intensity_label = Constants.label_for(INTENSITY_LABELS, @intensity) |
#interfering? ⇒ Boolean
51 52 53 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 51 def interfering? @intensity >= INTERFERENCE_THRESHOLD end |
#persistence ⇒ Object
55 56 57 58 59 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 55 def persistence return 0.0 if @original_intensity.zero? (@intensity / @original_intensity).clamp(0.0, 1.0).round(10) end |
#priming? ⇒ Boolean
47 48 49 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 47 def priming? @intensity >= PRIMING_THRESHOLD end |
#reinforce!(amount = REINFORCEMENT) ⇒ Object
34 35 36 37 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 34 def reinforce!(amount = REINFORCEMENT) @intensity = (@intensity + amount).clamp(0.0, 1.0).round(10) self end |
#silent? ⇒ Boolean
39 40 41 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 39 def silent? @intensity <= SILENT_THRESHOLD end |
#to_h ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/legion/extensions/agentic/memory/echo/helpers/echo.rb', line 64 def to_h { id: @id, content: @content, echo_type: @echo_type, domain: @domain, intensity: @intensity, original_intensity: @original_intensity, intensity_label: intensity_label, effect_label: effect_label, priming: priming?, interfering: interfering?, silent: silent?, persistence: persistence, decay_count: @decay_count, created_at: @created_at } end |