Class: Legion::Extensions::Agentic::Inference::UncertaintyTolerance::Helpers::Decision
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::UncertaintyTolerance::Helpers::Decision
- Defined in:
- lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb
Instance Attribute Summary collapse
-
#acted_despite_uncertainty ⇒ Object
readonly
Returns the value of attribute acted_despite_uncertainty.
-
#actual_outcome ⇒ Object
Returns the value of attribute actual_outcome.
-
#certainty_level ⇒ Object
readonly
Returns the value of attribute certainty_level.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#tolerance_at_time ⇒ Object
readonly
Returns the value of attribute tolerance_at_time.
Instance Method Summary collapse
- #decision_type ⇒ Object
-
#initialize(description:, domain:, certainty_level:, tolerance_at_time:) ⇒ Decision
constructor
A new instance of Decision.
- #resolve!(outcome:) ⇒ Object
- #risky? ⇒ Boolean
- #successful? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(description:, domain:, certainty_level:, tolerance_at_time:) ⇒ Decision
Returns a new instance of Decision.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 16 def initialize(description:, domain:, certainty_level:, tolerance_at_time:) @id = SecureRandom.uuid @description = description @domain = domain @certainty_level = certainty_level.clamp(0.0, 1.0) @tolerance_at_time = tolerance_at_time @actual_outcome = nil @acted_despite_uncertainty = certainty_level < tolerance_at_time @created_at = Time.now.utc end |
Instance Attribute Details
#acted_despite_uncertainty ⇒ Object (readonly)
Returns the value of attribute acted_despite_uncertainty.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 12 def acted_despite_uncertainty @acted_despite_uncertainty end |
#actual_outcome ⇒ Object
Returns the value of attribute actual_outcome.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 14 def actual_outcome @actual_outcome end |
#certainty_level ⇒ Object (readonly)
Returns the value of attribute certainty_level.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 12 def certainty_level @certainty_level end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 12 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 12 def description @description end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 12 def id @id end |
#tolerance_at_time ⇒ Object (readonly)
Returns the value of attribute tolerance_at_time.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 12 def tolerance_at_time @tolerance_at_time end |
Instance Method Details
#decision_type ⇒ Object
40 41 42 43 44 45 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 40 def decision_type Constants::CERTAINTY_THRESHOLDS.each do |type, threshold| return type if @certainty_level >= threshold end :unknown end |
#resolve!(outcome:) ⇒ Object
27 28 29 30 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 27 def resolve!(outcome:) @actual_outcome = outcome self end |
#risky? ⇒ Boolean
36 37 38 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 36 def risky? @certainty_level < 0.4 end |
#successful? ⇒ Boolean
32 33 34 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 32 def successful? @actual_outcome == :success end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb', line 47 def to_h { id: @id, description: @description, domain: @domain, certainty_level: @certainty_level, actual_outcome: @actual_outcome, tolerance_at_time: @tolerance_at_time, decision_type: decision_type, acted_despite_uncertainty: @acted_despite_uncertainty, created_at: @created_at } end |