Class: RubyLLM::Model::PricingCategory

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

Overview

Represents pricing tiers for different usage categories (standard and batch)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ PricingCategory

Returns a new instance of PricingCategory.



9
10
11
12
# File 'lib/ruby_llm/model/pricing_category.rb', line 9

def initialize(data = {})
  @standard = PricingTier.new(data[:standard] || {}) unless empty_tier?(data[:standard])
  @batch = PricingTier.new(data[:batch] || {}) unless empty_tier?(data[:batch])
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.



7
8
9
# File 'lib/ruby_llm/model/pricing_category.rb', line 7

def batch
  @batch
end

#standardObject (readonly)

Returns the value of attribute standard.



7
8
9
# File 'lib/ruby_llm/model/pricing_category.rb', line 7

def standard
  @standard
end

Instance Method Details

#[](key) ⇒ Object



26
27
28
# File 'lib/ruby_llm/model/pricing_category.rb', line 26

def [](key)
  key == :batch ? batch : standard
end

#cached_inputObject



22
23
24
# File 'lib/ruby_llm/model/pricing_category.rb', line 22

def cached_input
  standard&.cached_input_per_million
end

#inputObject



14
15
16
# File 'lib/ruby_llm/model/pricing_category.rb', line 14

def input
  standard&.input_per_million
end

#outputObject



18
19
20
# File 'lib/ruby_llm/model/pricing_category.rb', line 18

def output
  standard&.output_per_million
end

#to_hObject



30
31
32
33
34
35
# File 'lib/ruby_llm/model/pricing_category.rb', line 30

def to_h
  result = {}
  result[:standard] = standard.to_h if standard
  result[:batch] = batch.to_h if batch
  result
end