Class: VoyageAI::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/voyageai/config.rb

Overview

A configuration for VoyageAI.

@example:

VoyageAI.configure do |config|
  config.api_key = '...'
  config.host = 'https://api.voyageai.com'
  config.version = 'v1'
  config.logger = Logger.new(STDOUT)
  config.timeout = 15
end

Constant Summary collapse

DEFAULT_HOST =
"https://api.voyageai.com"
DEFAULT_VERSION =
"v1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: ENV.fetch("VOYAGEAI_API_KEY", nil), host: ENV.fetch("VOYAGEAI_HOST", DEFAULT_HOST), version: ENV.fetch("VOYAGEAI_VERSION", DEFAULT_VERSION), logger: nil, timeout: nil) ⇒ Config

Returns a new instance of Config.

Parameters:

  • api_key (String) (defaults to: ENV.fetch("VOYAGEAI_API_KEY", nil))

    optional - defaults to ‘ENV`

  • host (String) (defaults to: ENV.fetch("VOYAGEAI_HOST", DEFAULT_HOST))

    optional - defaults to ‘ENV“ w/ fallback to `api.voyageai.com`

  • version (String) (defaults to: ENV.fetch("VOYAGEAI_VERSION", DEFAULT_VERSION))

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

  • logger (Logger) (defaults to: nil)

    optional

  • timeout (Integer) (defaults to: nil)

    optional



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/voyageai/config.rb', line 43

def initialize(
  api_key: ENV.fetch("VOYAGEAI_API_KEY", nil),
  host: ENV.fetch("VOYAGEAI_HOST", DEFAULT_HOST),
  version: ENV.fetch("VOYAGEAI_VERSION", DEFAULT_VERSION),
  logger: nil,
  timeout: nil
)
  @api_key = api_key
  @host = host
  @version = version
  @logger = logger
  @timeout = timeout
end

Instance Attribute Details

#api_keyString?

Returns:

  • (String, nil)


20
21
22
# File 'lib/voyageai/config.rb', line 20

def api_key
  @api_key
end

#hostString?

Returns:

  • (String, nil)


24
25
26
# File 'lib/voyageai/config.rb', line 24

def host
  @host
end

#loggerLogger?

Returns:

  • (Logger, nil)


32
33
34
# File 'lib/voyageai/config.rb', line 32

def logger
  @logger
end

#timeoutInteger?

Returns:

  • (Integer, nil)


36
37
38
# File 'lib/voyageai/config.rb', line 36

def timeout
  @timeout
end

#versionString?

Returns:

  • (String, nil)


28
29
30
# File 'lib/voyageai/config.rb', line 28

def version
  @version
end