Class: RailsAiBridge::Tools::ProvenanceLines
- Inherits:
-
Object
- Object
- RailsAiBridge::Tools::ProvenanceLines
- Defined in:
- lib/rails_ai_bridge/tools/provenance_lines.rb
Overview
Renders confidence tags into tool output when confidence_tags_enabled is on.
With tags off, every method returns its input unchanged, so tool output stays byte-identical to output rendered before tags existed.
Instance Method Summary collapse
-
#footer(provenances) ⇒ String?
Verification summary line, or
nilwhen disabled or empty. -
#initialize(enabled) ⇒ ProvenanceLines
constructor
A new instance of ProvenanceLines.
-
#tag(text, provenance) ⇒ String
textwith a trailing tag when enabled.
Constructor Details
#initialize(enabled) ⇒ ProvenanceLines
Returns a new instance of ProvenanceLines.
11 12 13 |
# File 'lib/rails_ai_bridge/tools/provenance_lines.rb', line 11 def initialize(enabled) @enabled = enabled end |
Instance Method Details
#footer(provenances) ⇒ String?
Returns verification summary line, or nil when disabled or empty.
26 27 28 29 30 |
# File 'lib/rails_ai_bridge/tools/provenance_lines.rb', line 26 def (provenances) return unless @enabled ConfidenceTag.(provenances.map { |source| source || :heuristic }.tally) end |
#tag(text, provenance) ⇒ String
Returns text with a trailing tag when enabled.
18 19 20 21 22 |
# File 'lib/rails_ai_bridge/tools/provenance_lines.rb', line 18 def tag(text, provenance) return text unless @enabled ConfidenceTag.tagged(text, provenance) end |