Class: Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::CognitiveInput
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::CognitiveInput
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb
Constant Summary
Constants included from Constants
Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::ATTENTION_THRESHOLD, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::DEFAULT_EFFECT, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::DEFAULT_EFFORT, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::EFFECT_CEILING, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::EFFECT_DECAY, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::EFFECT_FLOOR, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::EFFECT_TYPES, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::EFFORT_CEILING, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::EFFORT_FLOOR, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::EFFORT_INFLATION, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::INPUT_TYPES, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::MAX_CONTEXTS, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::MAX_HISTORY, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::MAX_INPUTS, Legion::Extensions::Agentic::Attention::RelevanceTheory::Helpers::Constants::RELEVANCE_LABELS
Instance Attribute Summary collapse
-
#cognitive_effect ⇒ Object
readonly
Returns the value of attribute cognitive_effect.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#effect_type ⇒ Object
readonly
Returns the value of attribute effect_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input_type ⇒ Object
readonly
Returns the value of attribute input_type.
-
#processing_effort ⇒ Object
readonly
Returns the value of attribute processing_effort.
-
#source_id ⇒ Object
readonly
Returns the value of attribute source_id.
Instance Method Summary collapse
- #decay! ⇒ Object
- #increase_effort!(amount: 0.1) ⇒ Object
-
#initialize(content:, input_type:, context:, cognitive_effect: DEFAULT_EFFECT, processing_effort: DEFAULT_EFFORT, effect_type: :new_implication, source_id: nil) ⇒ CognitiveInput
constructor
A new instance of CognitiveInput.
- #normalized_relevance ⇒ Object
- #relevance ⇒ Object
- #relevance_label ⇒ Object
- #strengthen!(amount: 0.1) ⇒ Object
- #to_h ⇒ Object
- #weaken!(amount: 0.1) ⇒ Object
- #worth_processing? ⇒ Boolean
Constructor Details
#initialize(content:, input_type:, context:, cognitive_effect: DEFAULT_EFFECT, processing_effort: DEFAULT_EFFORT, effect_type: :new_implication, source_id: nil) ⇒ CognitiveInput
Returns a new instance of CognitiveInput.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 17 def initialize(content:, input_type:, context:, cognitive_effect: DEFAULT_EFFECT, processing_effort: DEFAULT_EFFORT, effect_type: :new_implication, source_id: nil) @id = SecureRandom.uuid @content = content @input_type = input_type @context = context @cognitive_effect = cognitive_effect.clamp(EFFECT_FLOOR, EFFECT_CEILING) @processing_effort = processing_effort.clamp(EFFORT_FLOOR, EFFORT_CEILING) @effect_type = effect_type @source_id = source_id @created_at = Time.now.utc end |
Instance Attribute Details
#cognitive_effect ⇒ Object (readonly)
Returns the value of attribute cognitive_effect.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def cognitive_effect @cognitive_effect end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def content @content end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def context @context end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def created_at @created_at end |
#effect_type ⇒ Object (readonly)
Returns the value of attribute effect_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def effect_type @effect_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def id @id end |
#input_type ⇒ Object (readonly)
Returns the value of attribute input_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def input_type @input_type end |
#processing_effort ⇒ Object (readonly)
Returns the value of attribute processing_effort.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def processing_effort @processing_effort end |
#source_id ⇒ Object (readonly)
Returns the value of attribute source_id.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 14 def source_id @source_id end |
Instance Method Details
#decay! ⇒ Object
60 61 62 63 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 60 def decay! @cognitive_effect = (@cognitive_effect - EFFECT_DECAY).clamp(EFFECT_FLOOR, EFFECT_CEILING) @processing_effort = (@processing_effort + EFFORT_INFLATION).clamp(EFFORT_FLOOR, EFFORT_CEILING) end |
#increase_effort!(amount: 0.1) ⇒ Object
56 57 58 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 56 def increase_effort!(amount: 0.1) @processing_effort = (@processing_effort + amount).clamp(EFFORT_FLOOR, EFFORT_CEILING) end |
#normalized_relevance ⇒ Object
35 36 37 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 35 def normalized_relevance relevance.clamp(0.0, 1.0) end |
#relevance ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 31 def relevance @cognitive_effect / @processing_effort end |
#relevance_label ⇒ Object
39 40 41 42 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 39 def relevance_label nr = normalized_relevance RELEVANCE_LABELS.find { |range, _| range.cover?(nr) }&.last || :irrelevant end |
#strengthen!(amount: 0.1) ⇒ Object
48 49 50 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 48 def strengthen!(amount: 0.1) @cognitive_effect = (@cognitive_effect + amount).clamp(EFFECT_FLOOR, EFFECT_CEILING) end |
#to_h ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 65 def to_h { id: @id, content: @content, input_type: @input_type, context: @context, cognitive_effect: @cognitive_effect, processing_effort: @processing_effort, relevance: relevance.round(3), normalized: normalized_relevance.round(3), relevance_label: relevance_label, worth_processing: worth_processing?, effect_type: @effect_type, source_id: @source_id, created_at: @created_at } end |
#weaken!(amount: 0.1) ⇒ Object
52 53 54 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 52 def weaken!(amount: 0.1) @cognitive_effect = (@cognitive_effect - amount).clamp(EFFECT_FLOOR, EFFECT_CEILING) end |
#worth_processing? ⇒ Boolean
44 45 46 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/helpers/cognitive_input.rb', line 44 def worth_processing? normalized_relevance >= ATTENTION_THRESHOLD end |