Module: Llmemory::LLM

Defined in:
lib/llmemory/llm.rb,
lib/llmemory/llm/base.rb,
lib/llmemory/llm/openai.rb,
lib/llmemory/llm/anthropic.rb

Defined Under Namespace

Classes: Anthropic, Base, OpenAI

Class Method Summary collapse

Class Method Details

.client(api_key: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/llmemory/llm.rb', line 9

def self.client(api_key: nil)
  opts = api_key.to_s.empty? ? {} : { api_key: api_key }
  case Llmemory.configuration.llm_provider.to_sym
  when :openai then OpenAI.new(**opts)
  when :anthropic then Anthropic.new(**opts)
  else
    raise Llmemory::ConfigurationError, "Unknown LLM provider: #{Llmemory.configuration.llm_provider}"
  end
end