Class: Legion::Extensions::Llm::Anthropic::Provider
- Inherits:
-
Provider
- Object
- Provider
- Legion::Extensions::Llm::Anthropic::Provider
- 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(_text, model:, dimensions:) ⇒ Object
- #headers ⇒ Object
- #list_models ⇒ Object
- #models_url ⇒ Object
- #stream_url ⇒ Object
Class Attribute Details
.registry_publisher ⇒ Object
19 20 21 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 19 def registry_publisher @registry_publisher ||= RegistryPublisher.new end |
Class Method Details
.capabilities ⇒ Object
17 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 17 def capabilities = Capabilities |
.configuration_options ⇒ Object
15 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 15 def = %i[anthropic_api_key anthropic_api_base anthropic_version] |
.configuration_requirements ⇒ Object
16 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 16 def configuration_requirements = %i[anthropic_api_key] |
.slug ⇒ Object
14 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 14 def slug = 'anthropic' |
Instance Method Details
#api_base ⇒ Object
35 36 37 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 35 def api_base config.anthropic_api_base || 'https://api.anthropic.com' end |
#completion_url ⇒ Object
46 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 46 def completion_url = '/v1/messages' |
#embed(_text, model:, dimensions:) ⇒ Object
50 51 52 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 50 def (_text, model:, dimensions:) raise NotImplementedError, 'Anthropic does not expose embeddings through this provider' end |
#headers ⇒ Object
39 40 41 42 43 44 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 39 def headers { 'x-api-key' => config.anthropic_api_key, 'anthropic-version' => config.anthropic_version || '2023-06-01' }.compact end |
#list_models ⇒ Object
54 55 56 57 58 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 54 def list_models super.tap do |models| self.class.registry_publisher.publish_models_async(models, readiness: readiness(live: false)) end end |
#models_url ⇒ Object
48 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 48 def models_url = '/v1/models' |
#stream_url ⇒ Object
47 |
# File 'lib/legion/extensions/llm/anthropic/provider.rb', line 47 def stream_url = completion_url |