Class: Legion::Extensions::Agentic::Inference::ArgumentMapping::Helpers::Argument
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::ArgumentMapping::Helpers::Argument
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb
Constant Summary
Constants included from Constants
Constants::ARGUMENT_STRENGTHS, Constants::BACKING_WEIGHT, Constants::DECAY_RATE, Constants::DEFAULT_STRENGTH, Constants::GROUND_WEIGHT, Constants::MAX_ARGUMENTS, Constants::MAX_HISTORY, Constants::QUALIFIER_TYPES, Constants::REBUTTAL_IMPACT_LABELS, Constants::REBUTTAL_PENALTY, Constants::WARRANT_WEIGHT
Instance Attribute Summary collapse
-
#backing ⇒ Object
readonly
Returns the value of attribute backing.
-
#claim ⇒ Object
readonly
Returns the value of attribute claim.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#grounds ⇒ Object
readonly
Returns the value of attribute grounds.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#qualifier ⇒ Object
readonly
Returns the value of attribute qualifier.
-
#rebuttals ⇒ Object
readonly
Returns the value of attribute rebuttals.
-
#warrant ⇒ Object
readonly
Returns the value of attribute warrant.
Instance Method Summary collapse
- #add_backing(backing:) ⇒ Object
- #add_ground(ground:) ⇒ Object
- #add_rebuttal(content:, impact: 0.5) ⇒ Object
-
#initialize(id:, claim:, domain: :general, warrant: nil, qualifier: :presumably) ⇒ Argument
constructor
A new instance of Argument.
- #rebutted? ⇒ Boolean
- #sound? ⇒ Boolean
- #strength ⇒ Object
- #strength_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(id:, claim:, domain: :general, warrant: nil, qualifier: :presumably) ⇒ Argument
Returns a new instance of Argument.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 15 def initialize(id:, claim:, domain: :general, warrant: nil, qualifier: :presumably) @id = id @claim = claim @domain = domain @warrant = warrant @qualifier = qualifier @grounds = [] @backing = [] @rebuttals = [] @created_at = Time.now.utc end |
Instance Attribute Details
#backing ⇒ Object (readonly)
Returns the value of attribute backing.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def backing @backing end |
#claim ⇒ Object (readonly)
Returns the value of attribute claim.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def claim @claim end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def domain @domain end |
#grounds ⇒ Object (readonly)
Returns the value of attribute grounds.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def grounds @grounds end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def id @id end |
#qualifier ⇒ Object (readonly)
Returns the value of attribute qualifier.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def qualifier @qualifier end |
#rebuttals ⇒ Object (readonly)
Returns the value of attribute rebuttals.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def rebuttals @rebuttals end |
#warrant ⇒ Object (readonly)
Returns the value of attribute warrant.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 12 def warrant @warrant end |
Instance Method Details
#add_backing(backing:) ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 31 def add_backing(backing:) @backing << backing end |
#add_ground(ground:) ⇒ Object
27 28 29 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 27 def add_ground(ground:) @grounds << ground end |
#add_rebuttal(content:, impact: 0.5) ⇒ Object
35 36 37 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 35 def add_rebuttal(content:, impact: 0.5) @rebuttals << { content: content, impact: impact.clamp(0.0, 1.0) } end |
#rebutted? ⇒ Boolean
55 56 57 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 55 def rebutted? @rebuttals.any? { |r| r[:impact] > 0.5 } end |
#sound? ⇒ Boolean
51 52 53 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 51 def sound? strength >= 0.6 && !@warrant.nil? && !@grounds.empty? end |
#strength ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 39 def strength raw = (ground_score * GROUND_WEIGHT) + (warrant_score * WARRANT_WEIGHT) + (backing_score * BACKING_WEIGHT) - (rebuttal_score * REBUTTAL_PENALTY) raw.clamp(0.0, 1.0) end |
#strength_label ⇒ Object
47 48 49 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 47 def strength_label ARGUMENT_STRENGTHS.find { |range, _| range.cover?(strength) }&.last end |
#to_h ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb', line 59 def to_h { id: @id, claim: @claim, domain: @domain, grounds: @grounds, warrant: @warrant, backing: @backing, qualifier: @qualifier, rebuttals: @rebuttals, strength: strength, strength_label: strength_label, sound: sound?, rebutted: rebutted?, created_at: @created_at } end |