Class: Legion::Extensions::Agentic::Inference::CausalAttribution::Helpers::Attribution
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::CausalAttribution::Helpers::Attribution
- Defined in:
- lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb
Constant Summary collapse
- MAX_ATTRIBUTIONS =
200- MAX_HISTORY =
300- LOCUS_VALUES =
%i[internal external].freeze
- STABILITY_VALUES =
%i[stable unstable].freeze
- CONTROLLABILITY_VALUES =
%i[controllable uncontrollable].freeze
- DEFAULT_CONFIDENCE =
0.5- CONFIDENCE_FLOOR =
0.0- CONFIDENCE_CEILING =
1.0- DECAY_RATE =
0.02- ATTRIBUTION_EMOTIONS =
{ %i[internal stable controllable] => :guilt, %i[internal stable uncontrollable] => :shame, %i[internal unstable controllable] => :regret, %i[internal unstable uncontrollable] => :surprise, %i[external stable controllable] => :anger, %i[external stable uncontrollable] => :helplessness, %i[external unstable controllable] => :frustration, %i[external unstable uncontrollable] => :relief }.freeze
Instance Attribute Summary collapse
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#controllability ⇒ Object
readonly
Returns the value of attribute controllability.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#emotional_response ⇒ Object
readonly
Returns the value of attribute emotional_response.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#locus ⇒ Object
readonly
Returns the value of attribute locus.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#stability ⇒ Object
readonly
Returns the value of attribute stability.
Instance Method Summary collapse
- #controllable? ⇒ Boolean
- #external? ⇒ Boolean
-
#initialize(event:, outcome:, domain:, locus:, stability:, controllability:, confidence: DEFAULT_CONFIDENCE) ⇒ Attribution
constructor
A new instance of Attribution.
- #internal? ⇒ Boolean
- #pattern ⇒ Object
- #stable? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(event:, outcome:, domain:, locus:, stability:, controllability:, confidence: DEFAULT_CONFIDENCE) ⇒ Attribution
Returns a new instance of Attribution.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 38 def initialize(event:, outcome:, domain:, locus:, stability:, controllability:, confidence: DEFAULT_CONFIDENCE) @id = SecureRandom.uuid @event = event @outcome = outcome @domain = domain @locus = locus @stability = stability @controllability = controllability @confidence = confidence.clamp(CONFIDENCE_FLOOR, CONFIDENCE_CEILING) @emotional_response = ATTRIBUTION_EMOTIONS[pattern] @created_at = Time.now.utc end |
Instance Attribute Details
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def confidence @confidence end |
#controllability ⇒ Object (readonly)
Returns the value of attribute controllability.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def controllability @controllability end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def domain @domain end |
#emotional_response ⇒ Object (readonly)
Returns the value of attribute emotional_response.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def emotional_response @emotional_response end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def event @event end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def id @id end |
#locus ⇒ Object (readonly)
Returns the value of attribute locus.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def locus @locus end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def outcome @outcome end |
#stability ⇒ Object (readonly)
Returns the value of attribute stability.
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 35 def stability @stability end |
Instance Method Details
#controllable? ⇒ Boolean
68 69 70 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 68 def controllable? controllability == :controllable end |
#external? ⇒ Boolean
60 61 62 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 60 def external? locus == :external end |
#internal? ⇒ Boolean
56 57 58 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 56 def internal? locus == :internal end |
#pattern ⇒ Object
52 53 54 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 52 def pattern [locus, stability, controllability] end |
#stable? ⇒ Boolean
64 65 66 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 64 def stable? stability == :stable end |
#to_h ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb', line 72 def to_h { id: id, event: event, outcome: outcome, domain: domain, locus: locus, stability: stability, controllability: controllability, confidence: confidence, emotional_response: emotional_response, created_at: created_at } end |