Class: Legion::Extensions::Agentic::Memory::EchoChamber::Helpers::Echo
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::EchoChamber::Helpers::Echo
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb
Constant Summary
Constants included from Constants
Constants::AMPLIFICATION_LABELS, Constants::AMPLIFICATION_RATE, Constants::BREAKTHROUGH_BONUS, Constants::CHAMBER_STATES, Constants::CHAMBER_STATE_LABELS, Constants::DECAY_RATE, Constants::DEFAULT_AMPLITUDE, Constants::DEFAULT_WALL_THICKNESS, Constants::DISRUPTION_THRESHOLD, Constants::ECHO_TYPES, Constants::MAX_CHAMBERS, Constants::MAX_ECHOES, Constants::POROUS_THRESHOLD, Constants::RESONANCE_LABELS, Constants::SEALED_THRESHOLD, Constants::SILENT_THRESHOLD
Instance Attribute Summary collapse
-
#amplitude ⇒ Object
readonly
Returns the value of attribute amplitude.
-
#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.
-
#echo_type ⇒ Object
readonly
Returns the value of attribute echo_type.
-
#frequency ⇒ Object
readonly
Returns the value of attribute frequency.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#original_amplitude ⇒ Object
readonly
Returns the value of attribute original_amplitude.
-
#source_agent ⇒ Object
readonly
Returns the value of attribute source_agent.
Instance Method Summary collapse
- #amplify!(rate = AMPLIFICATION_RATE) ⇒ Object
- #amplitude_label ⇒ Object
- #dampen!(rate = DECAY_RATE) ⇒ Object
- #fading? ⇒ Boolean
- #frequency_label ⇒ Object
-
#initialize(content:, echo_type: :belief, domain: :general, source_agent: nil, amplitude: DEFAULT_AMPLITUDE) ⇒ Echo
constructor
A new instance of Echo.
- #resonate? ⇒ Boolean
- #silent? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(content:, echo_type: :belief, domain: :general, source_agent: nil, amplitude: DEFAULT_AMPLITUDE) ⇒ Echo
Returns a new instance of Echo.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 17 def initialize(content:, echo_type: :belief, domain: :general, source_agent: nil, amplitude: DEFAULT_AMPLITUDE) @id = SecureRandom.uuid @content = content @echo_type = validate_type(echo_type) @domain = domain.to_sym @source_agent = source_agent @amplitude = amplitude.to_f.clamp(0.0, 1.0).round(10) @original_amplitude = @amplitude @frequency = 1 @created_at = Time.now.utc end |
Instance Attribute Details
#amplitude ⇒ Object (readonly)
Returns the value of attribute amplitude.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14 def amplitude @amplitude end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/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_chamber/helpers/echo.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/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_chamber/helpers/echo.rb', line 14 def echo_type @echo_type end |
#frequency ⇒ Object (readonly)
Returns the value of attribute frequency.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14 def frequency @frequency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14 def id @id end |
#original_amplitude ⇒ Object (readonly)
Returns the value of attribute original_amplitude.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14 def original_amplitude @original_amplitude end |
#source_agent ⇒ Object (readonly)
Returns the value of attribute source_agent.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14 def source_agent @source_agent end |
Instance Method Details
#amplify!(rate = AMPLIFICATION_RATE) ⇒ Object
30 31 32 33 34 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 30 def amplify!(rate = AMPLIFICATION_RATE) @frequency += 1 @amplitude = (@amplitude + rate).clamp(0.0, 1.0).round(10) self end |
#amplitude_label ⇒ Object
57 58 59 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 57 def amplitude_label Constants.label_for(AMPLIFICATION_LABELS, @amplitude) end |
#dampen!(rate = DECAY_RATE) ⇒ Object
36 37 38 39 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 36 def dampen!(rate = DECAY_RATE) @amplitude = (@amplitude - rate).clamp(0.0, 1.0).round(10) self end |
#fading? ⇒ Boolean
45 46 47 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 45 def fading? @amplitude <= POROUS_THRESHOLD end |
#frequency_label ⇒ Object
53 54 55 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 53 def frequency_label Constants.label_for(RESONANCE_LABELS, frequency_score) end |
#resonate? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 41 def resonate? @amplitude >= DISRUPTION_THRESHOLD end |
#silent? ⇒ Boolean
49 50 51 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 49 def silent? @amplitude <= SILENT_THRESHOLD end |
#to_h ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 61 def to_h { id: @id, content: @content, echo_type: @echo_type, domain: @domain, source_agent: @source_agent, amplitude: @amplitude, original_amplitude: @original_amplitude, frequency: @frequency, frequency_label: frequency_label, amplitude_label: amplitude_label, resonate: resonate?, fading: fading?, silent: silent?, created_at: @created_at } end |