module AiSummary
Constants
- IRC_CTRL
- IRC_RESET
- STYLE_DURATION
- STYLE_META
- STYLE_MODEL
- STYLE_TOKENS
- STYLE_USAGE_API
- STYLE_USAGE_AUTO
- STYLE_USAGE_TOTAL
Public Class Methods
Source
# File lib/ai/summary.rb, line 72 def self.format_answer(text, model:, total_tokens:, duration_s:, usage_percents: nil) lines = text.to_s.strip.split("\n").map(&:strip).reject(&:empty?) lines = ["No response"] if lines.empty? footer = format_footer( model: model, total_tokens: total_tokens, duration_s: duration_s, usage_percents: usage_percents ) lines[-1] = "#{lines[-1]} #{footer}" lines.join("\n") end
Source
# File lib/ai/summary.rb, line 65 def self.format_build_success_message(filename:, attempts:, model:, total_tokens:, duration_s:, usage_percents: nil) prefix = "Plugin #{filename} built in #{attempts} attempt(s) " "#{prefix}#{format_footer(model: model, total_tokens: total_tokens, duration_s: duration_s, usage_percents: usage_percents)}" end
Source
# File lib/ai/summary.rb, line 49 def self.format_stats_percentages(usage_percents) return "" if usage_percents.nil? auto = format_usage_percent(usage_percents[:auto_percent_used], STYLE_USAGE_AUTO) api = format_usage_percent(usage_percents[:api_percent_used], STYLE_USAGE_API) total = format_usage_percent(usage_percents[:total_percent_used], STYLE_USAGE_TOTAL) "#{STYLE_META} ยท #{IRC_RESET}#{auto}#{api}#{total}" end
Source
# File lib/ai/summary.rb, line 41 def self.format_usage_percent(value, style) format("#{style}%d%%#{IRC_RESET}", value.to_i) end
Source
# File lib/ai/summary.rb, line 14 def self.irc_color(fg, bg = nil) IrcFormat.color(fg, bg) end
Source
# File lib/ai/summary.rb, line 22 def self.token_style_colors [1, 8] end
Source
# File lib/ai/summary.rb, line 45 def self.usage_percent_separator "#{IRC_RESET}#{STYLE_META} ยท #{IRC_RESET}" end
Source
# File lib/ai/summary.rb, line 26 def self.usage_percent_style_colors(kind) case kind when :auto then [0, 10] when :api then [0, 12] when :total then [0, 13] else raise ArgumentError, "unknown usage percent kind: #{kind}" end end