Class: RubyLLM::RedCandle::Provider

Inherits:
Provider
  • Object
show all
Includes:
Capabilities, Chat, Models, Streaming
Defined in:
lib/ruby_llm/red_candle/provider.rb

Overview

Red Candle provider for local LLM execution using the Candle Rust crate.

Constant Summary

Constants included from Models

Models::SUPPORTED_MODELS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Streaming

#stream

Methods included from Capabilities

available_on_platform?, default_max_tokens, max_temperature, min_temperature, model_context_window, model_families, normalize_temperature, supports_audio?, supports_embeddings?, supports_pdf?, supports_regex_constraints?, supports_repetition_penalty?, supports_seed?, supports_stop_sequences?, supports_streaming?, supports_structured_output?, supports_temperature?, supports_top_k?, supports_top_p?, supports_vision?

Methods included from Models

#gguf_file_for, #list_models, #model, #model_available?, #model_ids, #model_info, #models, #supports_chat?, #supports_structured?, #tokenizer_for

Methods included from Chat

#complete, #perform_completion!, #perform_streaming_completion!, #render_payload

Constructor Details

#initialize(config) ⇒ Provider

Returns a new instance of Provider.



14
15
16
17
18
19
# File 'lib/ruby_llm/red_candle/provider.rb', line 14

def initialize(config)
  ensure_red_candle_available!
  super
  @loaded_models = {} # Cache for loaded models
  @device = determine_device(config)
end

Class Method Details

.capabilitiesObject



30
31
32
# File 'lib/ruby_llm/red_candle/provider.rb', line 30

def capabilities
  Capabilities
end

.configuration_requirementsObject



34
35
36
# File 'lib/ruby_llm/red_candle/provider.rb', line 34

def configuration_requirements
  [] # No required config, device is optional
end

.local?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/ruby_llm/red_candle/provider.rb', line 38

def local?
  true
end

.modelsObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ruby_llm/red_candle/provider.rb', line 46

def models
  # Return Red Candle models for registration
  Models::SUPPORTED_MODELS.map do |model_data|
    RubyLLM::Model::Info.new(
      id: model_data[:id],
      name: model_data[:name],
      provider: "red_candle",
      type: "chat",
      family: model_data[:family],
      context_window: model_data[:context_window],
      capabilities: %w[streaming structured_output],
      modalities: { input: %w[text], output: %w[text] }
    )
  end
end

.supports_functions?(model_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/ruby_llm/red_candle/provider.rb', line 42

def supports_functions?(model_id = nil)
  Capabilities.supports_functions?(model_id)
end

Instance Method Details

#api_baseObject



21
22
23
# File 'lib/ruby_llm/red_candle/provider.rb', line 21

def api_base
  nil # Local execution, no API base needed
end

#headersObject



25
26
27
# File 'lib/ruby_llm/red_candle/provider.rb', line 25

def headers
  {} # No HTTP headers needed
end