Class: LLM::Model

Inherits:
Object show all
Defined in:
lib/llm/model.rb

Overview

The LLM::Model class represents an LLM model that is available to use. Its properties are delegated to the underlying response body, and vary by provider.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#[], #[]=, #each, #empty?, #initialize, #to_h

Constructor Details

This class inherits a constructor from LLM::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class LLM::Object

Instance Attribute Details

#providerLLM::Provider

Returns a subclass of LLM::Provider

Returns:



11
12
13
# File 'lib/llm/model.rb', line 11

def provider
  @provider
end

Instance Method Details

#idString

Returns the model ID

Returns:

  • (String)


16
17
18
19
20
21
22
23
24
25
# File 'lib/llm/model.rb', line 16

def id
  case @provider.class.to_s
  when "LLM::Ollama"
    self["name"]
  when "LLM::Gemini"
    self["name"].sub(%r|\Amodels/|, "")
  else
    self["id"]
  end
end

#to_jsonString

Returns:

  • (String)


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

def to_json(*)
  id.to_json(*)
end