Class: ActiveGenie::Config::Providers::AnthropicConfig

Inherits:
ProviderBase
  • Object
show all
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

#organization

Instance Method Summary collapse

Methods inherited from ProviderBase

#valid?

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_versionString

Retrieves the Anthropic version. Defaults to ‘2023-06-01’.

Returns:

  • (String)

    The Anthropic version.



33
34
35
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 33

def anthropic_version
  @anthropic_version || '2023-06-01'
end

#api_keyString?

Retrieves the API key. Falls back to the ANTHROPIC_API_KEY environment variable if not set.

Returns:

  • (String, nil)

    The API key.



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_urlString

Retrieves the base API URL for Anthropic API. Defaults to ‘api.anthropic.com’.

Returns:

  • (String)

    The API base URL.



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_modelObject



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_hObject



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

Returns:

  • (Boolean)


41
42
43
# File 'lib/active_genie/configs/providers/anthropic_config.rb', line 41

def valid_model?(model)
  model.include?('claude')
end