Module: Legion::Extensions::Agentic::Defense::Confabulation::Runners::Confabulation
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/defense/confabulation/runners/confabulation.rb
Instance Method Summary collapse
- #confabulation_report ⇒ Object
- #confabulation_status ⇒ Object
- #flag_confabulation(claim_id:) ⇒ Object
- #high_risk_claims ⇒ Object
- #register_claim(content:, claim_type: :factual, confidence: 0.5, evidence_strength: 0.5) ⇒ Object
- #verify_claim(claim_id:) ⇒ Object
Instance Method Details
#confabulation_report ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/legion/extensions/agentic/defense/confabulation/runners/confabulation.rb', line 45 def confabulation_report(**) report = confabulation_engine.confabulation_report log.debug("[confabulation] report: total=#{report[:total_claims]} " \ "high_risk=#{report[:high_risk_claims]} " \ "rate=#{report[:confabulation_rate].round(2)} label=#{report[:risk_label]}") report end |
#confabulation_status ⇒ Object
59 60 61 |
# File 'lib/legion/extensions/agentic/defense/confabulation/runners/confabulation.rb', line 59 def confabulation_status(**) { engine: confabulation_engine.to_h } end |
#flag_confabulation(claim_id:) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/legion/extensions/agentic/defense/confabulation/runners/confabulation.rb', line 35 def flag_confabulation(claim_id:, **) result = confabulation_engine.flag_confabulation(claim_id: claim_id) if result[:found] log.warn("[confabulation] flagged: claim_id=#{claim_id} marked as confabulated") else log.debug("[confabulation] flag: claim_id=#{claim_id} not found") end result end |
#high_risk_claims ⇒ Object
53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/defense/confabulation/runners/confabulation.rb', line 53 def high_risk_claims(**) claims = confabulation_engine.high_risk_claims log.debug("[confabulation] high_risk_claims: count=#{claims.size}") { claims: claims.map(&:to_h), count: claims.size } end |
#register_claim(content:, claim_type: :factual, confidence: 0.5, evidence_strength: 0.5) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/defense/confabulation/runners/confabulation.rb', line 13 def register_claim(content:, claim_type: :factual, confidence: 0.5, evidence_strength: 0.5, **) claim = confabulation_engine.register_claim( content: content, claim_type: claim_type, confidence: confidence, evidence_strength: evidence_strength ) log.debug("[confabulation] register: id=#{claim.id} type=#{claim.claim_type} " \ "risk=#{claim.confabulation_risk.round(2)} label=#{claim.risk_label}") claim.to_h end |
#verify_claim(claim_id:) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/legion/extensions/agentic/defense/confabulation/runners/confabulation.rb', line 25 def verify_claim(claim_id:, **) result = confabulation_engine.verify_claim(claim_id: claim_id) if result[:found] log.info("[confabulation] verified: claim_id=#{claim_id}") else log.debug("[confabulation] verify: claim_id=#{claim_id} not found") end result end |