Class: LLM::Registry
- Inherits:
-
Object
- Object
- LLM::Registry
- Defined in:
- lib/llm/registry.rb
Overview
The LLM::Registry class provides a
small API over provider model data. It exposes model metadata such as
pricing, capabilities, modalities, and limits from the registry files
stored under data/. The data is provided by https://models.dev and shipped with
llm.rb.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(blob) ⇒ LLM::Registry constructor
-
#cost(model:) ⇒
LLM::Object
Returns model costs.
-
#modalities(model:)
⇒ LLM::Object
Returns model modalities.
-
#limit(model:) ⇒
LLM::Object
Returns model limits such as the context window size.
Constructor Details
#initialize(blob) ⇒ LLM::Registry
31 32 33 34 |
# File 'lib/llm/registry.rb', line 31 def initialize(blob) @registry = LLM::Object.from(blob) @models = @registry.models end |
Class Method Details
.for(name) ⇒ LLM::Registry
18 19 20 21 22 23 24 25 |
# File 'lib/llm/registry.rb', line 18 def self.for(name) path = File.join @root, "data", "#{name}.json" if File.file?(path) new LLM.json.load(File.binread(path)) else raise LLM::NoSuchRegistryError, "no registry found for #{name}" end end |
Instance Method Details
#cost(model:) ⇒ LLM::Object
Returns model costs
39 40 41 |
# File 'lib/llm/registry.rb', line 39 def cost(model:) lookup(model:).cost end |
#modalities(model:) ⇒ LLM::Object
Returns model modalities
46 47 48 |
# File 'lib/llm/registry.rb', line 46 def modalities(model:) lookup(model:).modalities end |
#limit(model:) ⇒ LLM::Object
Returns model limits such as the context window size
53 54 55 |
# File 'lib/llm/registry.rb', line 53 def limit(model:) lookup(model:).limit end |