Module: Admin::AiUsageLogsHelper

Defined in:
app/helpers/admin/ai_usage_logs_helper.rb

Overview

View helpers for the AI Usage & Cost dashboard.

Instance Method Summary collapse

Instance Method Details

#ai_usage_unpriced_tooltip(row) ⇒ String

Human explanation of why some/all calls in a rollup row are unpriced,
split into the two distinct causes so the dashboard stops conflating
"we never captured token usage" with "we have no price for this model".

Parameters:

  • row (Hash)

    a @by_feature / @by_model rollup row

Returns:

  • (String)

    tooltip text



12
13
14
15
16
17
18
# File 'app/helpers/admin/ai_usage_logs_helper.rb', line 12

def ai_usage_unpriced_tooltip(row)
  reasons = []
  reasons << "#{number_with_delimiter(row[:no_token_count])} missing captured usage (streaming/tool turns)" if row[:no_token_count].to_i.positive?
  reasons << "#{number_with_delimiter(row[:no_price_count])} missing a model price" if row[:no_price_count].to_i.positive?

  "#{number_with_delimiter(row[:null_cost_count])} of #{number_with_delimiter(row[:calls])} calls unpriced — #{reasons.join('; ')}"
end