Class: RubyLLM::ModelInfo

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

Overview

Information about an AI model’s capabilities, pricing, and metadata. Used by the Models registry to help developers choose the right model for their needs.

Example:

model = RubyLLM.models.find('gpt-4')
model.supports_vision?          # => true
model.supports_functions?       # => true
model.input_price_per_million   # => 30.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ModelInfo

rubocop:disable Metrics/AbcSize,Metrics/MethodLength



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby_llm/model_info.rb', line 20

def initialize(data) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  @id = data[:id]
  @created_at = data[:created_at].is_a?(String) ? Time.parse(data[:created_at]) : data[:created_at]
  @display_name = data[:display_name]
  @provider = data[:provider]
  @context_window = data[:context_window]
  @max_tokens = data[:max_tokens]
  @supports_vision = data[:supports_vision]
  @supports_functions = data[:supports_functions]
  @supports_json_mode = data[:supports_json_mode]
  @input_price_per_million = data[:input_price_per_million]
  @output_price_per_million = data[:output_price_per_million]
  @metadata = data[:metadata] || {}
end

Instance Attribute Details

#context_windowObject (readonly)

Returns the value of attribute context_window.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def context_window
  @context_window
end

#created_atObject (readonly)

Returns the value of attribute created_at.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def created_at
  @created_at
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def display_name
  @display_name
end

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def id
  @id
end

#input_price_per_millionObject (readonly)

Returns the value of attribute input_price_per_million.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def input_price_per_million
  @input_price_per_million
end

#max_tokensObject (readonly)

Returns the value of attribute max_tokens.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def max_tokens
  @max_tokens
end

#metadataObject (readonly)

Returns the value of attribute metadata.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def 
  @metadata
end

#output_price_per_millionObject (readonly)

Returns the value of attribute output_price_per_million.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def output_price_per_million
  @output_price_per_million
end

#providerObject (readonly)

Returns the value of attribute provider.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def provider
  @provider
end

#supports_functionsObject (readonly)

Returns the value of attribute supports_functions.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def supports_functions
  @supports_functions
end

#supports_json_modeObject (readonly)

Returns the value of attribute supports_json_mode.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def supports_json_mode
  @supports_json_mode
end

#supports_visionObject (readonly)

Returns the value of attribute supports_vision.



16
17
18
# File 'lib/ruby_llm/model_info.rb', line 16

def supports_vision
  @supports_vision
end

Instance Method Details

#familyObject



56
57
58
# File 'lib/ruby_llm/model_info.rb', line 56

def family
  ['family']
end

#to_hObject

rubocop:disable Metrics/MethodLength



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ruby_llm/model_info.rb', line 35

def to_h # rubocop:disable Metrics/MethodLength
  {
    id: id,
    created_at: created_at.iso8601,
    display_name: display_name,
    provider: provider,
    context_window: context_window,
    max_tokens: max_tokens,
    supports_vision: supports_vision,
    supports_functions: supports_functions,
    supports_json_mode: supports_json_mode,
    input_price_per_million: input_price_per_million,
    output_price_per_million: output_price_per_million,
    metadata: 
  }
end

#typeObject



52
53
54
# File 'lib/ruby_llm/model_info.rb', line 52

def type
  ['type']
end