Module: RubyLLM::Provider

Included in:
RubyLLM::Providers::Anthropic, RubyLLM::Providers::OpenAI
Defined in:
lib/ruby_llm/provider.rb

Overview

Base interface for LLM providers like OpenAI and Anthropic. Handles the complexities of API communication, streaming responses, and error handling so individual providers can focus on their unique features.

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.for(model) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/ruby_llm/provider.rb', line 90

def for(model)
  model_info = Models.find(model)
  provider_class = providers[model_info.provider.to_sym] or
    raise Error, "No provider registered for #{model_info.provider}"

  provider_class.new
end

.included(base) ⇒ Object



8
9
10
# File 'lib/ruby_llm/provider.rb', line 8

def self.included(base)
  base.include(InstanceMethods)
end

.register(name, provider_class) ⇒ Object



86
87
88
# File 'lib/ruby_llm/provider.rb', line 86

def register(name, provider_class)
  providers[name.to_sym] = provider_class
end