Class: RubyLLM::Providers::Test

Inherits:
Provider
  • Object
show all
Includes:
Echo
Defined in:
lib/ruby_llm/providers/test.rb

Overview

In-memory provider intended for tests.

This provider mirrors the behavior of a local fake adapter:

  • it does not initialize any remote connections,

  • it returns deterministic responses based on model-specific helpers (for example, ‘echo_response` from `Test::Echo`).

Defined Under Namespace

Modules: Echo

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Echo

id, info

Constructor Details

#initializeTest

Returns a new instance of Test.



20
21
22
23
# File 'lib/ruby_llm/providers/test.rb', line 20

def initialize(...)
  # configuration not needed
  # skip any connections
end

Class Method Details

.local?Boolean

Returns:

  • (Boolean)


18
# File 'lib/ruby_llm/providers/test.rb', line 18

def self.local? = true

Instance Method Details

#complete(messages, model:) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/ruby_llm/providers/test.rb', line 25

def complete(messages, model:, **)
  Message.new(
    role:     :assistant,
    model_id: model.id,

    **send("#{model.id}_response", messages)
  ).tap do |message|
    yield message.content if block_given?
  end
end

#list_modelsObject



36
37
# File 'lib/ruby_llm/providers/test.rb', line 36

def list_models = [Echo]
.map(&:info)