Module: RubyLLM::Models
- Defined in:
- lib/ruby_llm/models.rb
Class Method Summary collapse
- .all ⇒ Object
- .audio_models ⇒ Object
- .by_family(family) ⇒ Object
- .chat_models ⇒ Object
- .default_model ⇒ Object
- .embedding_models ⇒ Object
- .find(model_id) ⇒ Object
- .image_models ⇒ Object
- .provider_for(model) ⇒ Object
- .refresh! ⇒ Object
Class Method Details
.all ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ruby_llm/models.rb', line 11 def all @all ||= begin data = JSON.parse(File.read(File.('models.json', __dir__))) data['models'].map { |model| ModelInfo.new(model.transform_keys(&:to_sym)) } end rescue Errno::ENOENT [] # Return empty array if file doesn't exist yet end |
.audio_models ⇒ Object
32 33 34 |
# File 'lib/ruby_llm/models.rb', line 32 def audio_models all.select { |m| m.type == 'audio' } end |
.by_family(family) ⇒ Object
40 41 42 |
# File 'lib/ruby_llm/models.rb', line 40 def by_family(family) all.select { |m| m.family == family } end |
.chat_models ⇒ Object
24 25 26 |
# File 'lib/ruby_llm/models.rb', line 24 def chat_models all.select { |m| m.type == 'chat' } end |
.default_model ⇒ Object
44 45 46 |
# File 'lib/ruby_llm/models.rb', line 44 def default_model 'gpt-4o-mini' end |
.embedding_models ⇒ Object
28 29 30 |
# File 'lib/ruby_llm/models.rb', line 28 def all.select { |m| m.type == 'embedding' } end |
.find(model_id) ⇒ Object
20 21 22 |
# File 'lib/ruby_llm/models.rb', line 20 def find(model_id) all.find { |m| m.id == model_id } or raise Error, "Unknown model: #{model_id}" end |
.image_models ⇒ Object
36 37 38 |
# File 'lib/ruby_llm/models.rb', line 36 def image_models all.select { |m| m.type == 'image' } end |
.provider_for(model) ⇒ Object
7 8 9 |
# File 'lib/ruby_llm/models.rb', line 7 def provider_for(model) Provider.for(model) end |
.refresh! ⇒ Object
48 49 50 |
# File 'lib/ruby_llm/models.rb', line 48 def refresh! @all = nil end |