Module: LlmCostTracker::Usage::Catalog
- Defined in:
- lib/llm_cost_tracker/usage/catalog.rb
Constant Summary collapse
- DEFINITIONS_PATH =
File.("dimensions.yml", __dir__)
- DEFAULT_RATE_BASIS_BY_UNIT =
{ "token" => "per_million_tokens", "character" => "per_million_characters", "request" => "per_request", "session" => "per_session", "hour" => "per_hour", "minute" => "per_minute", "image" => "per_image" }.freeze
Class Method Summary collapse
- .all ⇒ Object
- .find_by(kind:, direction:, modality:, cache_state:, unit:) ⇒ Object
- .token_priced ⇒ Object
- .token_priced_for(kind:, direction:, cache_state:) ⇒ Object
Class Method Details
.all ⇒ Object
26 27 28 |
# File 'lib/llm_cost_tracker/usage/catalog.rb', line 26 def all @all ||= load_definitions.freeze end |
.find_by(kind:, direction:, modality:, cache_state:, unit:) ⇒ Object
34 35 36 |
# File 'lib/llm_cost_tracker/usage/catalog.rb', line 34 def find_by(kind:, direction:, modality:, cache_state:, unit:) by_attributes[[kind, direction, modality, cache_state, unit]] end |
.token_priced ⇒ Object
30 31 32 |
# File 'lib/llm_cost_tracker/usage/catalog.rb', line 30 def token_priced @token_priced ||= all.select(&:token_key).freeze end |
.token_priced_for(kind:, direction:, cache_state:) ⇒ Object
38 39 40 41 42 |
# File 'lib/llm_cost_tracker/usage/catalog.rb', line 38 def token_priced_for(kind:, direction:, cache_state:) token_priced.find do |dimension| dimension.kind == kind && dimension.direction == direction && dimension.cache_state == cache_state end end |