Class: Legion::Extensions::Agentic::Social::Mentalizing::Helpers::BeliefAttribution
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Social::Mentalizing::Helpers::BeliefAttribution
- Defined in:
- lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb
Instance Attribute Summary collapse
-
#about_agent_id ⇒ Object
readonly
Returns the value of attribute about_agent_id.
-
#agent_id ⇒ Object
readonly
Returns the value of attribute agent_id.
-
#confidence ⇒ Object
Returns the value of attribute confidence.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #decay ⇒ Object
-
#initialize(agent_id:, subject:, content:, confidence:, depth: 0, about_agent_id: nil) ⇒ BeliefAttribution
constructor
A new instance of BeliefAttribution.
- #label ⇒ Object
- #reinforce(amount: Constants::CONFIDENCE_ALPHA) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(agent_id:, subject:, content:, confidence:, depth: 0, about_agent_id: nil) ⇒ BeliefAttribution
Returns a new instance of BeliefAttribution.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 13 def initialize(agent_id:, subject:, content:, confidence:, depth: 0, about_agent_id: nil) @id = SecureRandom.uuid @agent_id = agent_id @subject = subject @content = content @confidence = confidence.clamp(0.0, 1.0) @depth = depth @about_agent_id = about_agent_id @created_at = Time.now.utc end |
Instance Attribute Details
#about_agent_id ⇒ Object (readonly)
Returns the value of attribute about_agent_id.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 10 def about_agent_id @about_agent_id end |
#agent_id ⇒ Object (readonly)
Returns the value of attribute agent_id.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 10 def agent_id @agent_id end |
#confidence ⇒ Object
Returns the value of attribute confidence.
11 12 13 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 11 def confidence @confidence end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 10 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 10 def created_at @created_at end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 10 def depth @depth end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 10 def id @id end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 10 def subject @subject end |
Instance Method Details
#decay ⇒ Object
24 25 26 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 24 def decay @confidence = [@confidence - Constants::BELIEF_DECAY, Constants::BELIEF_FLOOR].max end |
#label ⇒ Object
32 33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 32 def label Constants::CONFIDENCE_LABELS.each do |range, lbl| return lbl if range.cover?(@confidence) end :unknown end |
#reinforce(amount: Constants::CONFIDENCE_ALPHA) ⇒ Object
28 29 30 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 28 def reinforce(amount: Constants::CONFIDENCE_ALPHA) @confidence = [@confidence + amount, 1.0].min end |
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/legion/extensions/agentic/social/mentalizing/helpers/belief_attribution.rb', line 39 def to_h { id: @id, agent_id: @agent_id, subject: @subject, content: @content, confidence: @confidence, depth: @depth, about_agent_id: @about_agent_id, label: label, created_at: @created_at } end |