Module: RubyLLM::Provider::InstanceMethods

Defined in:
lib/ruby_llm/provider.rb

Overview

Common functionality for all LLM providers. Implements the core provider interface so specific providers only need to implement a few key methods.

Instance Method Summary collapse

Instance Method Details

#complete(messages, tools:, temperature:, model:, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/ruby_llm/provider.rb', line 15

def complete(messages, tools:, temperature:, model:, &block)
  payload = build_payload messages, tools: tools, temperature: temperature, model: model, stream: block_given?

  if block_given?
    stream_response payload, &block
  else
    sync_response payload
  end
end

#list_modelsObject



25
26
27
28
29
30
31
# File 'lib/ruby_llm/provider.rb', line 25

def list_models
  response = connection.get(models_url) do |req|
    req.headers.merge! headers
  end

  parse_list_models_response response
end