Class: RubyLLM::Providers::Test
- Inherits:
-
Provider
- Object
- Provider
- RubyLLM::Providers::Test
- 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
- #complete(messages, model:) ⇒ Object
-
#initialize ⇒ Test
constructor
A new instance of Test.
- #list_models ⇒ Object
Methods included from Echo
Constructor Details
#initialize ⇒ Test
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
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(, model:, **) Message.new( role: :assistant, model_id: model.id, **send("#{model.id}_response", ) ).tap do || yield .content if block_given? end end |
#list_models ⇒ Object
36 37 |
# File 'lib/ruby_llm/providers/test.rb', line 36 def list_models = [Echo] .map(&:info) |