Class: FuncBot::Bot

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBot

Returns a new instance of Bot.



18
19
20
21
22
# File 'lib/func_bot.rb', line 18

def initialize
  @history = Bots::History.new
  @client = Bots::Client.new(self)
  @include_functions = true
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



16
17
18
# File 'lib/func_bot.rb', line 16

def client
  @client
end

#historyObject (readonly)

Returns the value of attribute history.



16
17
18
# File 'lib/func_bot.rb', line 16

def history
  @history
end

#include_functionsObject

Returns the value of attribute include_functions.



15
16
17
# File 'lib/func_bot.rb', line 15

def include_functions
  @include_functions
end

#responseObject

Returns the value of attribute response.



15
16
17
# File 'lib/func_bot.rb', line 15

def response
  @response
end

Instance Method Details

#ask(prompt) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/func_bot.rb', line 24

def ask(prompt)
  history.chronicle("user", prompt)
  self.response = client.call
  self.response = Functions::Handler.new(self).handle if available_function?
  history.chronicle("assistant", content)
  history.messages.last.content
end