Class: Legion::Extensions::Llm::Anthropic::Provider

Inherits:
LexLLM::Provider
  • Object
show all
Defined in:
lib/legion/extensions/llm/anthropic/provider.rb

Overview

Anthropic Messages API provider implementation for the LexLLM contract.

Defined Under Namespace

Modules: Capabilities

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.capabilitiesObject



16
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 16

def capabilities = Capabilities

.configuration_optionsObject



14
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 14

def configuration_options = %i[anthropic_api_key anthropic_api_base anthropic_version]

.configuration_requirementsObject



15
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 15

def configuration_requirements = %i[anthropic_api_key]

.slugObject



13
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 13

def slug = 'anthropic'

Instance Method Details

#api_baseObject



30
31
32
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 30

def api_base
  config.anthropic_api_base || 'https://api.anthropic.com'
end

#completion_urlObject



41
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 41

def completion_url = '/v1/messages'

#embed(_text, model:, dimensions:) ⇒ Object

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 45

def embed(_text, model:, dimensions:)
  raise NotImplementedError, 'Anthropic does not expose embeddings through this provider'
end

#headersObject



34
35
36
37
38
39
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 34

def headers
  {
    'x-api-key' => config.anthropic_api_key,
    'anthropic-version' => config.anthropic_version || '2023-06-01'
  }.compact
end

#models_urlObject



43
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 43

def models_url = '/v1/models'

#stream_urlObject



42
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 42

def stream_url = completion_url