Module: LlmCostTracker::Pricing::EffectivePrices

Defined in:
lib/llm_cost_tracker/pricing/effective_prices.rb

Defined Under Namespace

Classes: Resolved

Class Method Summary collapse

Class Method Details

.call(usage:, quantities:, prices:, pricing_mode:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/llm_cost_tracker/pricing/effective_prices.rb', line 14

def call(usage:, quantities:, prices:, pricing_mode:)
  context_tier = context_tier?(usage: usage, prices: prices)
  orderings = pricing_mode && Mode.permutations_for(pricing_mode)

  quantities.to_h do |price_key, tokens|
    resolved = if tokens.positive?
                 price_for(
                   prices: prices,
                   key: price_key,
                   orderings: orderings,
                   context_tier: context_tier
                 )
               else
                 Resolved.new(amount: BigDecimal("0"), key: price_key)
               end
    [price_key, resolved]
  end
end