Class: RubyLLM::Providers::GPUStack

Inherits:
RubyLLM::Provider show all
Defined in:
lib/ruby_llm/providers/gpustack.rb,
lib/ruby_llm/providers/gpustack/chat.rb,
lib/ruby_llm/providers/gpustack/media.rb,
lib/ruby_llm/providers/gpustack/models.rb,
lib/ruby_llm/providers/gpustack/speech.rb,
lib/ruby_llm/providers/gpustack/embeddings.rb,
lib/ruby_llm/providers/gpustack/transcription.rb

Overview

GPUStack API integration.

Defined Under Namespace

Modules: Chat, Embeddings, Media, Models, Speech, Transcription Classes: ChatCompletions

Constant Summary

Constants included from Support::Inspectable

Support::Inspectable::TRUNCATE_AT

Instance Attribute Summary

Attributes inherited from RubyLLM::Provider

#config, #connection

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RubyLLM::Provider

#animate_later, #assume_models_exist?, assume_models_exist?, #batch_cost, #batch_cost_amounts, #batch_cost_multiplier, #batch_protocol_name, #batch_results, #batch_status, #batches?, #cache_content, #cancel_batch, #capabilities, capabilities, #compact, #complete, #configuration_requirements, configured?, #configured?, configured_providers, configured_remote_providers, #count_tokens, #create_batch, #delete_cache, display_name, #download_file, #embed, #extend_cache, #files?, #find_batch, #find_cache, #find_file, #find_research_job, #initialize, #list_file_uris, #list_models, #local?, local_providers, #long_context_pricing?, model_registry_files, model_required?, models_dev_alias, models_dev_model_id, #moderate, #name, #ocr, #paint, #parse_error, #preprocess_message, protocol, #protocol_for, protocols, #protocols, providers, register, remote?, remote_providers, #render, #render_embedding, #rerank, #research_later, resolve, resolve!, resolve_registry_id, #retry_delay, #slug, #speak, #tokenize, #tool_approval_response, #transcribe, #upload_file

Methods included from Support::Inspectable

#full_inspect, #inspect, #pretty_print

Constructor Details

This class inherits a constructor from RubyLLM::Provider

Class Method Details

.configuration_optionsObject



52
53
54
# File 'lib/ruby_llm/providers/gpustack.rb', line 52

def configuration_options
  i[gpustack_api_base gpustack_api_key]
end

.configuration_requirementsObject



56
57
58
# File 'lib/ruby_llm/providers/gpustack.rb', line 56

def configuration_requirements
  i[gpustack_api_base]
end

.local?Boolean

Returns:



60
61
62
# File 'lib/ruby_llm/providers/gpustack.rb', line 60

def local?
  true
end

Instance Method Details

#api_baseObject



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

def api_base
  @config.gpustack_api_base
end

#backend_api_baseObject

:nodoc:



33
34
35
36
37
38
39
40
41
# File 'lib/ruby_llm/providers/gpustack.rb', line 33

def backend_api_base # :nodoc:
  uri = URI(api_base)
  unless uri.path.match?(%r{/model/proxy/\d+/v1/?\z})
    raise Error, 'This GPUStack operation requires gpustack_api_base to end in /model/proxy/ROUTE_ID/v1'
  end

  uri.path = uri.path.sub(%r{/v1/?\z}, '')
  uri.to_s
end

#headersObject



43
44
45
46
47
48
49
# File 'lib/ruby_llm/providers/gpustack.rb', line 43

def headers
  return {} unless @config.gpustack_api_key

  {
    'Authorization' => "Bearer #{@config.gpustack_api_key}"
  }
end

#resolve_protocol(name, model, **request) ⇒ Object



23
24
25
26
27
# File 'lib/ruby_llm/providers/gpustack.rb', line 23

def resolve_protocol(name, model, **request)
  return fetch_protocol(:chat_completions) if !name && request[:operation]

  super
end