Class: LLM::Model

Inherits:
OpenStruct 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 included from OpenStruct::FromHash

#from_hash

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