Class: AIA::Client

Inherits:
Tools
  • Object
show all
Includes:
BackendCommon
Defined in:
lib/aia/tools/client.rb

Constant Summary collapse

DEFAULT_PARAMETERS =
''
DIRECTIVES =
[]

Instance Attribute Summary collapse

Attributes included from BackendCommon

#command, #files, #parameters, #text

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BackendCommon

#sanitize, #set_parameter_from_directives

Methods inherited from Tools

catalog, get_meta, inherited, load_tools, #meta, meta, search_for, setup_backend, validate_tools

Constructor Details

#initialize(text: "", files: []) ⇒ Client

Returns a new instance of Client.



25
26
27
28
29
# File 'lib/aia/tools/client.rb', line 25

def initialize(text: "", files: [])
  super

  @client     = OpenAI::Client.new
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



20
21
22
# File 'lib/aia/tools/client.rb', line 20

def client
  @client
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



20
21
22
# File 'lib/aia/tools/client.rb', line 20

def raw_response
  @raw_response
end

Class Method Details

.list_modelsObject



175
176
177
# File 'lib/aia/tools/client.rb', line 175

def list_models
  new.client.model.list      
end

.speak(what) ⇒ Object



180
181
182
183
184
185
186
187
# File 'lib/aia/tools/client.rb', line 180

def speak(what)
  save_model = AIA.config.model
  AIA.config.model = AIA.config.speech_model

  new(text: what).speak

  AIA.config.model = save_model
end

Instance Method Details

#build_commandObject



31
32
33
# File 'lib/aia/tools/client.rb', line 31

def build_command
  # No-Op
end

#runObject



36
37
38
39
40
# File 'lib/aia/tools/client.rb', line 36

def run
  handle_model(AIA.config.model)
rescue => e
  puts "Error handling model #{AIA.config.model}: #{e.message}"
end

#speak(what = @text) ⇒ Object



42
43
44
45
46
# File 'lib/aia/tools/client.rb', line 42

def speak(what = @text)
  print "Speaking ... " if AIA.verbose?
  text2audio(what)
  puts "Done."          if AIA.verbose?
end