Class: Legion::Extensions::Agentic::Language::Grammar::Helpers::Construction
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Language::Grammar::Helpers::Construction
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/language/grammar/helpers/construction.rb
Constant Summary
Constants included from Constants
Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::ACTIVATION_BOOST, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::ACTIVATION_DECAY, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::ACTIVATION_LABELS, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::CONSTRUAL_OPERATIONS, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::DEFAULT_ACTIVATION, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::ENTRENCHMENT_THRESHOLD, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::EXPRESSION_TYPES, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::MAX_CONSTRUALS, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::MAX_CONSTRUCTIONS, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::MAX_HISTORY, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::PROMINENCE_TYPES, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::SCOPE_LEVELS, Legion::Extensions::Agentic::Language::Grammar::Helpers::Constants::SPECIFICITY_LEVELS
Instance Attribute Summary collapse
-
#activation ⇒ Object
Returns the value of attribute activation.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#expression_type ⇒ Object
readonly
Returns the value of attribute expression_type.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#meaning ⇒ Object
readonly
Returns the value of attribute meaning.
-
#usage_count ⇒ Object
readonly
Returns the value of attribute usage_count.
Instance Method Summary collapse
- #activation_label ⇒ Object
- #decay! ⇒ Object
- #entrenched? ⇒ Boolean
-
#initialize(form:, meaning:, expression_type:, domain:, activation: DEFAULT_ACTIVATION) ⇒ Construction
constructor
A new instance of Construction.
- #to_h ⇒ Object
- #use! ⇒ Object
Constructor Details
#initialize(form:, meaning:, expression_type:, domain:, activation: DEFAULT_ACTIVATION) ⇒ Construction
Returns a new instance of Construction.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 17 def initialize(form:, meaning:, expression_type:, domain:, activation: DEFAULT_ACTIVATION) @id = SecureRandom.uuid @form = form @meaning = meaning @expression_type = expression_type.to_sym @activation = activation.clamp(0.0, 1.0) @usage_count = 0 @domain = domain @created_at = Time.now.utc end |
Instance Attribute Details
#activation ⇒ Object
Returns the value of attribute activation.
15 16 17 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 15 def activation @activation end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.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/language/grammar/helpers/construction.rb', line 14 def domain @domain end |
#expression_type ⇒ Object (readonly)
Returns the value of attribute expression_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 14 def expression_type @expression_type end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
14 15 16 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 14 def form @form end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 14 def id @id end |
#meaning ⇒ Object (readonly)
Returns the value of attribute meaning.
14 15 16 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 14 def meaning @meaning end |
#usage_count ⇒ Object (readonly)
Returns the value of attribute usage_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 14 def usage_count @usage_count end |
Instance Method Details
#activation_label ⇒ Object
43 44 45 46 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 43 def activation_label match = ACTIVATION_LABELS.find { |range, _| range.cover?(@activation) } match ? match.last : :ad_hoc end |
#decay! ⇒ Object
34 35 36 37 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 34 def decay! @activation = [@activation - ACTIVATION_DECAY, 0.0].max self end |
#entrenched? ⇒ Boolean
39 40 41 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 39 def entrenched? @activation >= ENTRENCHMENT_THRESHOLD end |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 48 def to_h { id: @id, form: @form, meaning: @meaning, expression_type: @expression_type, activation: @activation, usage_count: @usage_count, domain: @domain, entrenched: entrenched?, activation_label: activation_label, created_at: @created_at } end |
#use! ⇒ Object
28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/language/grammar/helpers/construction.rb', line 28 def use! @usage_count += 1 @activation = [@activation + ACTIVATION_BOOST, 1.0].min.round(10) self end |