diff options
author | icebaker <icebaker@proton.me> | 2023-12-07 20:38:49 -0300 |
---|---|---|
committer | icebaker <icebaker@proton.me> | 2023-12-07 20:38:49 -0300 |
commit | 9d9702b39db67ab66894e5483a267a05ea0f6a2d (patch) | |
tree | 165e52d98ade38c10eb7de91120208f0293a140c /controllers/session.rb | |
parent | 6a6b154f0453875d09bbf86127c475a2b9020aa7 (diff) |
adding tools medatada
Diffstat (limited to 'controllers/session.rb')
-rw-r--r-- | controllers/session.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/controllers/session.rb b/controllers/session.rb index 378a11d..aabcb41 100644 --- a/controllers/session.rb +++ b/controllers/session.rb @@ -11,6 +11,7 @@ require_relative '../logic/cartridge/streaming' require_relative '../logic/cartridge/interaction' require_relative '../logic/cartridge/fetch' require_relative 'interfaces/tools' +require_relative '../components/stream' require_relative '../components/storage' require_relative '../components/adapter' require_relative '../components/crypto' @@ -56,11 +57,19 @@ module NanoBot end def boot(mode:) - return unless Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot instruction]) + instruction = Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot instruction]) + return unless instruction behavior = Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot]) || {} - input = { behavior:, history: [] } + @state[:history] << { + who: 'user', + mode: mode.to_s, + input: instruction, + message: instruction + } + + input = { behavior:, history: @state[:history] } process(input, mode:) end @@ -182,8 +191,12 @@ module NanoBot @stream.flush end - def print(content) - @stream.write(content) + def print(content, meta = nil) + if @stream.is_a?(NanoBot::Components::Stream) + @stream.write(content, meta) + else + @stream.write(content) + end end end end |