Class: Legion::Extensions::Llm::Anthropic::Provider
- Inherits:
-
Provider
- Object
- Provider
- Legion::Extensions::Llm::Anthropic::Provider
- Includes:
- Logging::Helper
- Defined in:
- lib/legion/extensions/llm/anthropic/provider.rb
Overview
Anthropic Messages API provider implementation for the Legion::Extensions::Llm contract.
Defined Under Namespace
Modules: Capabilities
Class Attribute Summary collapse
Class Method Summary collapse
- .capabilities ⇒ Object
- .configuration_options ⇒ Object
- .configuration_requirements ⇒ Object
- .slug ⇒ Object
Instance Method Summary collapse
- #api_base ⇒ Object
- #completion_url ⇒ Object
- #embed(**_provider_options) ⇒ Object
- #headers ⇒ Object
- #list_models ⇒ Object
- #models_url ⇒ Object
- #stream_url ⇒ Object
Class Attribute Details
.registry_publisher ⇒ Object
22 23 24 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 22 def registry_publisher @registry_publisher ||= RegistryPublisher.new end |
Class Method Details
.capabilities ⇒ Object
20 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 20 def capabilities = Capabilities |
.configuration_options ⇒ Object
18 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 18 def = %i[anthropic_api_key anthropic_api_base anthropic_version] |
.configuration_requirements ⇒ Object
19 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 19 def configuration_requirements = %i[anthropic_api_key] |
.slug ⇒ Object
17 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 17 def slug = 'anthropic' |
Instance Method Details
#api_base ⇒ Object
38 39 40 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 38 def api_base config.anthropic_api_base || 'https://api.anthropic.com' end |
#completion_url ⇒ Object
49 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 49 def completion_url = '/v1/messages' |
#embed(**_provider_options) ⇒ Object
53 54 55 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 53 def (**) raise NotImplementedError, 'Anthropic does not expose embeddings through this provider' end |
#headers ⇒ Object
42 43 44 45 46 47 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 42 def headers { 'x-api-key' => config.anthropic_api_key, 'anthropic-version' => config.anthropic_version || '2023-06-01' }.compact end |
#list_models ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 57 def list_models(**) log.debug { 'listing available Anthropic models' } super.tap do |models| log.debug { "discovered #{Array(models).size} Anthropic model(s); publishing to registry" } self.class.registry_publisher.publish_models_async(models, readiness: readiness(live: false)) end end |
#models_url ⇒ Object
51 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 51 def models_url = '/v1/models' |
#stream_url ⇒ Object
50 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 50 def stream_url = completion_url |