Class: RubyLLM::Model::Pricing

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/model/pricing.rb

Overview

A collection that manages and provides access to different categories of pricing information

Constant Summary collapse

CATEGORIES =
%i[text_tokens images audio_tokens embeddings].freeze

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Pricing

Returns a new instance of Pricing.



9
10
11
12
13
14
15
# File 'lib/ruby_llm/model/pricing.rb', line 9

def initialize(data)
  @data = {}

  CATEGORIES.each do |category|
    @data[category] = PricingCategory.new(data[category]) if data[category] && !empty_pricing?(data[category])
  end
end

Instance Method Details

#audio_tokensObject



25
26
27
# File 'lib/ruby_llm/model/pricing.rb', line 25

def audio_tokens
  category(:audio_tokens)
end

#embeddingsObject



29
30
31
# File 'lib/ruby_llm/model/pricing.rb', line 29

def embeddings
  category(:embeddings)
end

#imagesObject



21
22
23
# File 'lib/ruby_llm/model/pricing.rb', line 21

def images
  category(:images)
end

#text_tokensObject



17
18
19
# File 'lib/ruby_llm/model/pricing.rb', line 17

def text_tokens
  category(:text_tokens)
end

#to_hObject



33
34
35
# File 'lib/ruby_llm/model/pricing.rb', line 33

def to_h
  @data.transform_values(&:to_h)
end