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), beta: ENV.fetch('ANTHROPIC_BETA', nil), 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`

  • beta (String, nil) (defaults to: ENV.fetch('ANTHROPIC_BETA', nil))

    optional - defaults to ‘ENV`

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

    optional - defaults to

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

    optional



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/omniai/anthropic/config.rb', line 24

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

Instance Attribute Details

#betaString?

Returns passed as ‘anthropic-beta` if specified.

Returns:

  • (String, nil)

    passed as ‘anthropic-beta` if specified



16
17
18
# File 'lib/omniai/anthropic/config.rb', line 16

def beta
  @beta
end

#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