Class: OmniAI::CLI::BaseHandler

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

Overview

A generic handler for CLI commands (e.g. ‘omnia chat’).

Direct Known Subclasses

ChatHandler, EmbedHandler

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdin: $stdin, stdout: $stdout, provider: 'openai') ⇒ BaseHandler

Returns a new instance of BaseHandler.

Parameters:

  • stdin (IO) (defaults to: $stdin)

    an optional stream for stdin

  • stdout (IO) (defaults to: $stdout)

    an optional stream for stdout

  • provider (String) (defaults to: 'openai')

    an optional provider (defaults to ‘openai’)



18
19
20
21
22
23
# File 'lib/omniai/cli/base_handler.rb', line 18

def initialize(stdin: $stdin, stdout: $stdout, provider: 'openai')
  @stdin = stdin
  @stdout = stdout
  @provider = provider
  @args = {}
end

Class Method Details

.handle!(argv:, stdin: $stdin, stdout: $stdout, provider: 'openai') ⇒ Object

Parameters:

  • stdin (IO) (defaults to: $stdin)

    an optional stream for stdin

  • stdout (IO) (defaults to: $stdout)

    an optional stream for stdout

  • provider (String) (defaults to: 'openai')

    an optional provider (defaults to ‘openai’)

  • argv (Array<String>)


11
12
13
# File 'lib/omniai/cli/base_handler.rb', line 11

def self.handle!(argv:, stdin: $stdin, stdout: $stdout, provider: 'openai')
  new(stdin:, stdout:, provider:).handle!(argv:)
end

Instance Method Details

#handle!(argv:) ⇒ Object

Parameters:

  • argv (Array<String>)

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/omniai/cli/base_handler.rb', line 26

def handle!(argv:)
  raise NotImplementedError, "#{self.class}#handle! undefined"
end