Class: ActiveGenie::Config::Providers::AnthropicConfig
- Inherits:
-
ProviderBase
- Object
- ProviderBase
- ActiveGenie::Config::Providers::AnthropicConfig
- Defined in:
- lib/active_genie/configs/providers/anthropic_config.rb
Overview
Configuration class for the Anthropic API client. Manages API keys, URLs, model selections, and client instantiation.
Instance Attribute Summary
Attributes inherited from ProviderBase
Instance Method Summary collapse
-
#anthropic_version ⇒ String
Retrieves the Anthropic version.
-
#api_key ⇒ String?
Retrieves the API key.
-
#api_url ⇒ String
Retrieves the base API URL for Anthropic API.
- #default_model ⇒ Object
-
#initialize(anthropic_version: nil, **args) ⇒ AnthropicConfig
constructor
A new instance of AnthropicConfig.
- #to_h ⇒ Object
- #valid_model?(model) ⇒ Boolean
Methods inherited from ProviderBase
Constructor Details
#initialize(anthropic_version: nil, **args) ⇒ AnthropicConfig
Returns a new instance of AnthropicConfig.
11 12 13 14 |
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 11 def initialize(anthropic_version: nil, **args) @anthropic_version = anthropic_version super(**args) end |
Instance Method Details
#anthropic_version ⇒ String
Retrieves the Anthropic version. Defaults to ‘2023-06-01’.
33 34 35 |
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 33 def anthropic_version @anthropic_version || '2023-06-01' end |
#api_key ⇒ String?
Retrieves the API key. Falls back to the ANTHROPIC_API_KEY environment variable if not set.
19 20 21 |
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 19 def api_key @api_key || ENV.fetch('ANTHROPIC_API_KEY', nil) end |
#api_url ⇒ String
Retrieves the base API URL for Anthropic API. Defaults to ‘api.anthropic.com’.
26 27 28 |
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 26 def api_url @api_url || 'https://api.anthropic.com' end |
#default_model ⇒ Object
37 38 39 |
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 37 def default_model @default_model || 'claude-3-5-haiku-20241022' end |
#to_h ⇒ Object
45 46 47 |
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 45 def to_h super.merge({ anthropic_version: }) end |
#valid_model?(model) ⇒ Boolean
41 42 43 |
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 41 def valid_model?(model) model.include?('claude') end |