Class: RubyPi::LLM::Model
- Inherits:
-
Object
- Object
- RubyPi::LLM::Model
- Defined in:
- lib/ruby_pi/llm/model.rb
Overview
A model descriptor that pairs a provider identifier with a specific model name. Use the factory method RubyPi::LLM.model to create provider instances directly, or instantiate a Model object for deferred construction.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The model name within the provider.
-
#provider ⇒ Symbol
readonly
The provider identifier (:gemini, :anthropic, :openai).
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Equality comparison based on provider and name.
-
#build(**options) ⇒ RubyPi::LLM::BaseProvider
Builds a configured provider instance from this model descriptor.
-
#hash ⇒ Integer
Hash code for use in hash keys and sets.
-
#initialize(provider:, name:) ⇒ Model
constructor
Creates a new Model descriptor.
-
#to_h ⇒ Hash
Returns a hash representation of the model descriptor.
-
#to_s ⇒ String
(also: #inspect)
Returns a human-readable string representation.
Constructor Details
#initialize(provider:, name:) ⇒ Model
Creates a new Model descriptor.
34 35 36 37 |
# File 'lib/ruby_pi/llm/model.rb', line 34 def initialize(provider:, name:) @provider = provider.to_sym @name = name.to_s end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the model name within the provider.
28 29 30 |
# File 'lib/ruby_pi/llm/model.rb', line 28 def name @name end |
#provider ⇒ Symbol (readonly)
Returns the provider identifier (:gemini, :anthropic, :openai).
25 26 27 |
# File 'lib/ruby_pi/llm/model.rb', line 25 def provider @provider end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Equality comparison based on provider and name.
68 69 70 |
# File 'lib/ruby_pi/llm/model.rb', line 68 def ==(other) other.is_a?(Model) && @provider == other.provider && @name == other.name end |
#build(**options) ⇒ RubyPi::LLM::BaseProvider
Builds a configured provider instance from this model descriptor. Delegates to RubyPi::LLM.model for provider construction.
44 45 46 |
# File 'lib/ruby_pi/llm/model.rb', line 44 def build(**) RubyPi::LLM.model(@provider, @name, **) end |
#hash ⇒ Integer
Hash code for use in hash keys and sets.
77 78 79 |
# File 'lib/ruby_pi/llm/model.rb', line 77 def hash [@provider, @name].hash end |
#to_h ⇒ Hash
Returns a hash representation of the model descriptor.
51 52 53 |
# File 'lib/ruby_pi/llm/model.rb', line 51 def to_h { provider: @provider, name: @name } end |
#to_s ⇒ String Also known as: inspect
Returns a human-readable string representation.
58 59 60 |
# File 'lib/ruby_pi/llm/model.rb', line 58 def to_s "#<RubyPi::LLM::Model provider=#{@provider.inspect} name=#{@name.inspect}>" end |