Module: RubyLLM::Providers::GPUStack::Models

Included in:
ChatCompletions
Defined in:
lib/ruby_llm/providers/gpustack/models.rb

Overview

Models methods of the GPUStack API integration. GPUStack 2.x serves the plain OpenAI list format at /v1/models; categories arrive through per-category queries because the list response doesn't include them.

Constant Summary collapse

CATEGORIES =
%w[llm embedding image reranker speech_to_text text_to_speech unknown].freeze

Instance Method Summary collapse

Instance Method Details

#list_modelsObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_llm/providers/gpustack/models.rb', line 16

def list_models
  models = {}
  CATEGORIES.each do |category|
    data = @connection.get("#{models_url}&categories=#{category}").body['data'] || []
    data.each do |model|
      entry = models[model['id']] ||= model.merge('categories' => [])
      entry['categories'] << category
    end
  end
  models.values.map { |model| build_model(model, @provider.slug) }
end

#models_urlObject



12
13
14
# File 'lib/ruby_llm/providers/gpustack/models.rb', line 12

def models_url
  'models?with_meta=true'
end

#parse_list_models_response(response, slug) ⇒ Object



28
29
30
31
# File 'lib/ruby_llm/providers/gpustack/models.rb', line 28

def parse_list_models_response(response, slug)
  data = response.body['data'] || []
  data.map { |model| build_model(model, slug) }
end