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



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

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)


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

def api_key
  @api_key
end

#chat_optionsHash

Returns:

  • (Hash)


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

def chat_options
  @chat_options
end

#hostString?

Returns:

  • (String, nil)


22
23
24
# File 'lib/omniai/config.rb', line 22

def host
  @host
end

#loggerLogger?

Returns:

  • (Logger, nil)


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

def logger
  @logger
end

#speak_optionsHash

Returns:

  • (Hash)


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

def speak_options
  @speak_options
end

#timeoutInteger, ...

Returns:

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


31
32
33
# File 'lib/omniai/config.rb', line 31

def timeout
  @timeout
end

#transcribe_optionsHash

Returns:

  • (Hash)


37
38
39
# File 'lib/omniai/config.rb', line 37

def transcribe_options
  @transcribe_options
end

Instance Method Details

#inspectString

Returns:

  • (String)


58
59
60
61
# File 'lib/omniai/config.rb', line 58

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