Class: Legion::Extensions::Agentic::Defense::Confabulation::Helpers::Claim
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::Confabulation::Helpers::Claim
- Defined in:
- lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb
Instance Attribute Summary collapse
-
#claim_type ⇒ Object
readonly
Returns the value of attribute claim_type.
-
#confabulated ⇒ Object
readonly
Returns the value of attribute confabulated.
-
#confidence ⇒ Object
readonly
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.
-
#evidence_strength ⇒ Object
readonly
Returns the value of attribute evidence_strength.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#verified ⇒ Object
readonly
Returns the value of attribute verified.
Instance Method Summary collapse
- #confabulation_risk ⇒ Object
-
#initialize(content:, claim_type:, confidence:, evidence_strength:) ⇒ Claim
constructor
A new instance of Claim.
- #mark_confabulated! ⇒ Object
- #risk_label ⇒ Object
- #to_h ⇒ Object
- #verify! ⇒ Object
Constructor Details
#initialize(content:, claim_type:, confidence:, evidence_strength:) ⇒ Claim
Returns a new instance of Claim.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 15 def initialize(content:, claim_type:, confidence:, evidence_strength:) @id = SecureRandom.uuid @content = content @claim_type = claim_type @confidence = confidence.clamp(0.0, 1.0) @evidence_strength = evidence_strength.clamp(0.0, 1.0) @verified = false @confabulated = false @created_at = Time.now.utc end |
Instance Attribute Details
#claim_type ⇒ Object (readonly)
Returns the value of attribute claim_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def claim_type @claim_type end |
#confabulated ⇒ Object (readonly)
Returns the value of attribute confabulated.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def confabulated @confabulated end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def confidence @confidence end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def created_at @created_at end |
#evidence_strength ⇒ Object (readonly)
Returns the value of attribute evidence_strength.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def evidence_strength @evidence_strength end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def id @id end |
#verified ⇒ Object (readonly)
Returns the value of attribute verified.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 12 def verified @verified end |
Instance Method Details
#confabulation_risk ⇒ Object
26 27 28 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 26 def confabulation_risk (confidence - evidence_strength).clamp(0.0, 1.0) end |
#mark_confabulated! ⇒ Object
35 36 37 38 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 35 def mark_confabulated! @confabulated = true self end |
#risk_label ⇒ Object
40 41 42 43 44 45 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 40 def risk_label Constants::RISK_LABELS.each do |range, label| return label if range.cover?(confabulation_risk) end :extreme end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 47 def to_h { id: id, content: content, claim_type: claim_type, confidence: confidence.round(10), evidence_strength: evidence_strength.round(10), confabulation_risk: confabulation_risk.round(10), risk_label: risk_label, verified: verified, confabulated: confabulated, created_at: created_at.iso8601 } end |
#verify! ⇒ Object
30 31 32 33 |
# File 'lib/legion/extensions/agentic/defense/confabulation/helpers/claim.rb', line 30 def verify! @verified = true self end |