Class: OmniAI::OpenAI::Config

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

Overview

Configuration for OpenAI.

Constant Summary collapse

DEFAULT_HOST =
"https://api.openai.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: ENV.fetch("OPENAI_API_KEY", nil), host: ENV.fetch("OPENAI_HOST", DEFAULT_HOST), organization: ENV.fetch("OPENAI_ORGANIZATION", nil), project: ENV.fetch("OPENAI_PROJECT", nil), logger: nil, timeout: nil) ⇒ Config

Returns a new instance of Config.

Parameters:

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

    optional - defaults to ‘ENV`

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

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

  • organization (String, nil) (defaults to: ENV.fetch("OPENAI_ORGANIZATION", nil))

    optional - defaults to ‘ENV`

  • project (String, nil) (defaults to: ENV.fetch("OPENAI_PROJECT", nil))

    optional - defaults to ‘ENV`

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

    optional

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

    optional



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

def initialize(
  api_key: ENV.fetch("OPENAI_API_KEY", nil),
  host: ENV.fetch("OPENAI_HOST", DEFAULT_HOST),
  organization: ENV.fetch("OPENAI_ORGANIZATION", nil),
  project: ENV.fetch("OPENAI_PROJECT", nil),
  logger: nil,
  timeout: nil
)
  super(api_key:, host:, logger:, timeout:)

  @organization = organization
  @project = project
end

Instance Attribute Details

#organizationString?

Returns passed as ‘OpenAI-Organization` if specified.

Returns:

  • (String, nil)

    passed as ‘OpenAI-Organization` if specified



11
12
13
# File 'lib/omniai/openai/config.rb', line 11

def organization
  @organization
end

#projectString?

Returns passed as ‘OpenAI-Organization` if specified.

Returns:

  • (String, nil)

    passed as ‘OpenAI-Organization` if specified



15
16
17
# File 'lib/omniai/openai/config.rb', line 15

def project
  @project
end