Class: Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Concept
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Concept
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb
Constant Summary
Constants included from Constants
Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Constants::DEFAULT_FLUENCY, Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Constants::FLUENCY_LABELS, Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Constants::MAX_CONCEPTS, Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Constants::NOVELTY_LABELS, Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Constants::RECOVERY_RATE, Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Constants::SATIATION_RATE, Legion::Extensions::Agentic::Memory::SemanticSatiation::Helpers::Constants::SATIATION_THRESHOLD
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#exposure_count ⇒ Object
readonly
Returns the value of attribute exposure_count.
-
#fluency ⇒ Object
readonly
Returns the value of attribute fluency.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#last_exposed_at ⇒ Object
readonly
Returns the value of attribute last_exposed_at.
Instance Method Summary collapse
- #expose! ⇒ Object
- #fluency_label ⇒ Object
-
#initialize(label:, domain: :general) ⇒ Concept
constructor
A new instance of Concept.
- #novelty ⇒ Object
- #novelty_label ⇒ Object
- #recover!(amount: RECOVERY_RATE) ⇒ Object
- #satiated? ⇒ Boolean
- #time_since_exposure ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(label:, domain: :general) ⇒ Concept
Returns a new instance of Concept.
17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 17 def initialize(label:, domain: :general) @id = SecureRandom.uuid @label = label @domain = domain @fluency = DEFAULT_FLUENCY @exposure_count = 0 @last_exposed_at = nil @created_at = Time.now.utc end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.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/semantic_satiation/helpers/concept.rb', line 14 def domain @domain end |
#exposure_count ⇒ Object (readonly)
Returns the value of attribute exposure_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 14 def exposure_count @exposure_count end |
#fluency ⇒ Object (readonly)
Returns the value of attribute fluency.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 14 def fluency @fluency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 14 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 14 def label @label end |
#last_exposed_at ⇒ Object (readonly)
Returns the value of attribute last_exposed_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 14 def last_exposed_at @last_exposed_at end |
Instance Method Details
#expose! ⇒ Object
27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 27 def expose! @exposure_count += 1 @fluency = (@fluency - SATIATION_RATE).clamp(0.0, DEFAULT_FLUENCY).round(10) @last_exposed_at = Time.now.utc end |
#fluency_label ⇒ Object
41 42 43 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 41 def fluency_label FLUENCY_LABELS.find { |range, _| range.cover?(fluency) }&.last || :meaningless end |
#novelty ⇒ Object
45 46 47 48 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 45 def novelty saturation = [exposure_count.to_f / 50.0, 1.0].min (DEFAULT_FLUENCY - saturation).clamp(0.0, DEFAULT_FLUENCY).round(10) end |
#novelty_label ⇒ Object
50 51 52 53 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 50 def novelty_label n = novelty NOVELTY_LABELS.find { |range, _| range.cover?(n) }&.last || :saturated end |
#recover!(amount: RECOVERY_RATE) ⇒ Object
33 34 35 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 33 def recover!(amount: RECOVERY_RATE) @fluency = (@fluency + amount).clamp(0.0, DEFAULT_FLUENCY).round(10) end |
#satiated? ⇒ Boolean
37 38 39 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 37 def satiated? fluency < (DEFAULT_FLUENCY - SATIATION_THRESHOLD) end |
#time_since_exposure ⇒ Object
55 56 57 58 59 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 55 def time_since_exposure return nil unless last_exposed_at Time.now.utc - last_exposed_at end |
#to_h ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb', line 61 def to_h { id: id, label: label, domain: domain, fluency: fluency, fluency_label: fluency_label, novelty: novelty, novelty_label: novelty_label, exposure_count: exposure_count, satiated: satiated?, last_exposed_at: last_exposed_at, created_at: created_at } end |