Module: LlmCostTracker::Pricing::Sync::RegistryDiff

Defined in:
lib/llm_cost_tracker/pricing/sync/registry_diff.rb

Class Method Summary collapse

Class Method Details

.call(current_models, updated_models) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/llm_cost_tracker/pricing/sync/registry_diff.rb', line 8

def call(current_models, updated_models)
  current_models = Registry.normalize_price_entries(current_models, context: "current price table")
  updated_models = Registry.normalize_price_entries(updated_models, context: "updated price table")

  (current_models.keys | updated_models.keys).sort.each_with_object({}) do |model, changes|
    fields = price_field_changes(current_models[model], updated_models[model])
    changes[model] = fields if fields.any?
  end
rescue ArgumentError, TypeError => e
  raise Error, e.message
end