Class: RubyLLM::Contract::Step::AdapterCaller
- Inherits:
-
Object
- Object
- RubyLLM::Contract::Step::AdapterCaller
- Defined in:
- lib/ruby_llm/contract/step/adapter_caller.rb
Instance Method Summary collapse
- #call(messages) ⇒ Object
-
#initialize(adapter:, adapter_options:) ⇒ AdapterCaller
constructor
A new instance of AdapterCaller.
Constructor Details
#initialize(adapter:, adapter_options:) ⇒ AdapterCaller
Returns a new instance of AdapterCaller.
7 8 9 10 |
# File 'lib/ruby_llm/contract/step/adapter_caller.rb', line 7 def initialize(adapter:, adapter_options:) @adapter = adapter @adapter_options = end |
Instance Method Details
#call(messages) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ruby_llm/contract/step/adapter_caller.rb', line 12 def call() start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) response = @adapter.call(messages: , **@adapter_options) latency_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start_time) * 1000).round [response, latency_ms] rescue StandardError => error [Result.new(status: :adapter_error, raw_output: nil, parsed_output: nil, validation_errors: [error.]), 0] end |