Class: RubyLLM::ModelInfo
- Inherits:
-
Object
- Object
- RubyLLM::ModelInfo
- 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
-
#context_window ⇒ Object
readonly
Returns the value of attribute context_window.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input_price_per_million ⇒ Object
readonly
Returns the value of attribute input_price_per_million.
-
#max_tokens ⇒ Object
readonly
Returns the value of attribute max_tokens.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#output_price_per_million ⇒ Object
readonly
Returns the value of attribute output_price_per_million.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#supports_functions ⇒ Object
readonly
Returns the value of attribute supports_functions.
-
#supports_json_mode ⇒ Object
readonly
Returns the value of attribute supports_json_mode.
-
#supports_vision ⇒ Object
readonly
Returns the value of attribute supports_vision.
Instance Method Summary collapse
- #family ⇒ Object
-
#initialize(data) ⇒ ModelInfo
constructor
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
-
#to_h ⇒ Object
rubocop:disable Metrics/MethodLength.
- #type ⇒ Object
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_window ⇒ Object (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_at ⇒ Object (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_name ⇒ Object (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 |
#id ⇒ Object (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_million ⇒ Object (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_tokens ⇒ Object (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 |
#metadata ⇒ Object (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_million ⇒ Object (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 |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
16 17 18 |
# File 'lib/ruby_llm/model_info.rb', line 16 def provider @provider end |
#supports_functions ⇒ Object (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_mode ⇒ Object (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_vision ⇒ Object (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
#family ⇒ Object
56 57 58 |
# File 'lib/ruby_llm/model_info.rb', line 56 def family ['family'] end |
#to_h ⇒ Object
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 |
#type ⇒ Object
52 53 54 |
# File 'lib/ruby_llm/model_info.rb', line 52 def type ['type'] end |