Class: RubyLLM::Mongoid::MongoidSource

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/mongoid/acts_as.rb

Overview


Model registry source — plugs into RubyLLM.config.model_registry_source


Instance Method Summary collapse

Instance Method Details

#readObject



170
171
172
173
174
175
176
177
178
# File 'lib/ruby_llm/mongoid/acts_as.rb', line 170

def read
  model_class = resolve_model_class
  return [] unless model_class.respond_to?(:all)

  model_class.all.map(&:to_llm)
rescue StandardError => e
  RubyLLM.logger.debug { "Failed to load models from MongoDB: #{e.message}, falling back to JSON" }
  []
end