Class: Rubino::API::Operations::Models::ListOperation
- Inherits:
-
Object
- Object
- Rubino::API::Operations::Models::ListOperation
- Defined in:
- lib/rubino/api/operations/models/list_operation.rb
Overview
GET /v1/models — returns the model catalog from ruby_llm. The source defaults to RubyLLM.models.all but accepts any callable returning an enumerable of model objects/hashes for tests.
Instance Method Summary collapse
- #call(_request) ⇒ Object
-
#initialize(model_source: nil) ⇒ ListOperation
constructor
Accepts an alternate model source (callable) for tests.
Constructor Details
#initialize(model_source: nil) ⇒ ListOperation
Accepts an alternate model source (callable) for tests.
14 15 16 |
# File 'lib/rubino/api/operations/models/list_operation.rb', line 14 def initialize(model_source: nil) @model_source = model_source || -> { RubyLLM.models.all } end |
Instance Method Details
#call(_request) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubino/api/operations/models/list_operation.rb', line 18 def call(_request) models = @model_source.call.map do |m| { id: model_id(m), provider: m.respond_to?(:provider) ? m.provider.to_s : nil, context_window: m.respond_to?(:context_window) ? m.context_window : nil } end [200, models] end |