Class: OmniAI::Config

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

Overview

A configuration for each agent w/ ‘api_key` / `host` / `logger`.

Usage:

OmniAI::OpenAI.config do |config|
  config.api_key = '...'
  config.host = 'http://localhost:8080'
  config.logger = Logger.new(STDOUT)
  config.timeout = 15
  config.chat_options = { ... }
  config.transcribe_options = { ... }
  config.speak_options = { ... }
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, host: nil, logger: nil, timeout: nil) ⇒ Config

Returns a new instance of Config.

Parameters:

  • api_key (String) (defaults to: nil)

    optional

  • host (String) (defaults to: nil)

    optional

  • logger (Logger) (defaults to: nil)

    optional

  • timeout (Integer) (defaults to: nil)

    optional



53
54
55
56
57
58
59
60
61
62
# File 'lib/omniai/config.rb', line 53

def initialize(api_key: nil, host: nil, logger: nil, timeout: nil)
  @api_key = api_key
  @host = host
  @logger = logger
  @timeout = timeout

  @chat_options = {}
  @transcribe_options = {}
  @speak_options = {}
end

Instance Attribute Details

#api_keyString?

Returns:

  • (String, nil)


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

def api_key
  @api_key
end

#chat_optionsHash

Returns:

  • (Hash)


39
40
41
# File 'lib/omniai/config.rb', line 39

def chat_options
  @chat_options
end

#hostString?

Returns:

  • (String, nil)


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

def host
  @host
end

#loggerLogger?

Returns:

  • (Logger, nil)


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

def logger
  @logger
end

#speak_optionsHash

Returns:

  • (Hash)


47
48
49
# File 'lib/omniai/config.rb', line 47

def speak_options
  @speak_options
end

#timeoutInteger, ...

Returns:

  • (Integer, Hash{Symbol => Integer}, nil)


35
36
37
# File 'lib/omniai/config.rb', line 35

def timeout
  @timeout
end

#transcribe_optionsHash

Returns:

  • (Hash)


43
44
45
# File 'lib/omniai/config.rb', line 43

def transcribe_options
  @transcribe_options
end

Instance Method Details

#inspectString

Returns:

  • (String)


65
66
67
68
# File 'lib/omniai/config.rb', line 65

def inspect
  masked_api_key = "#{api_key[..2]}***" if api_key
  "#<#{self.class.name} api_key=#{masked_api_key.inspect} host=#{host.inspect}>"
end