9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/llm_cost_tracker/pricing/effective_prices.rb', line 9
def call(usage:, prices:, pricing_mode:)
context_tier = context_tier?(usage: usage, prices: prices)
Billing::Components::TOKEN_PRICED.to_h do |component|
price_key = component.key
tokens = usage.public_send(component.token_key)
price = if tokens.positive?
price_for(
prices: prices,
key: price_key,
pricing_mode: pricing_mode,
context_tier: context_tier
)
else
0.0
end
[price_key, price]
end
end
|