Class: OmniAI::Anthropic::Config

Inherits:
Config
  • Object
show all
Defined in:
lib/omniai/anthropic/config.rb

Overview

Configuration for Anthropic.

Constant Summary collapse

DEFAULT_HOST =
'https://api.anthropic.com'
DEFAULT_VERSION =
'2023-06-01'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: ENV.fetch('ANTHROPIC_API_KEY', nil), host: ENV.fetch('ANTHROPIC_HOST', DEFAULT_HOST), version: ENV.fetch('ANTHROPIC_VERSION', DEFAULT_VERSION), logger: nil, timeout: nil) ⇒ Config

Returns a new instance of Config.

Parameters:

  • api_key (String, nil) (defaults to: ENV.fetch('ANTHROPIC_API_KEY', nil))

    optional - defaults to ‘ENV`

  • host (String, nil) (defaults to: ENV.fetch('ANTHROPIC_HOST', DEFAULT_HOST))

    optional - defaults to ‘ENV w/ fallback to `DEFAULT_HOST`

  • version (String, nil) (defaults to: ENV.fetch('ANTHROPIC_VERSION', DEFAULT_VERSION))

    optional - defaults to ‘ENV w/ fallback to `DEFAULT_VERSION`

  • logger (Logger, nil) (defaults to: nil)

    optional - defaults to

  • timeout (Integer, Hash, nil) (defaults to: nil)

    optional



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/omniai/anthropic/config.rb', line 19

def initialize(
  api_key: ENV.fetch('ANTHROPIC_API_KEY', nil),
  host: ENV.fetch('ANTHROPIC_HOST', DEFAULT_HOST),
  version: ENV.fetch('ANTHROPIC_VERSION', DEFAULT_VERSION),
  logger: nil,
  timeout: nil
)
  super(api_key:, host:, logger:, timeout:)
  @version = version
  @chat_options[:max_tokens] = 4096
end

Instance Attribute Details

#versionString?

Returns passed as ‘anthropic-version` if specified.

Returns:

  • (String, nil)

    passed as ‘anthropic-version` if specified



12
13
14
# File 'lib/omniai/anthropic/config.rb', line 12

def version
  @version
end