controllers/session.rb in nano-bots-0.0.1 vs controllers/session.rb in nano-bots-0.0.2

- old
+ new

@@ -65,29 +65,31 @@ input = { behavior:, history: @state[:history] } process(input, mode:) end - def process(input, mode:) - streaming = @provider.settings[:stream] && Logic::Helpers::Hash.fetch( - @cartridge, [:interfaces, mode.to_sym, :stream] - ) + def stream(interface) + provider = @provider.settings.key?(:stream) ? @provider.settings[:stream] : true + interface = interface.key?(:stream) ? interface[:stream] : true + provider && interface + end + + def process(input, mode:) interface = Logic::Helpers::Hash.fetch(@cartridge, [:interfaces, mode.to_sym]) || {} + streaming = stream(interface) + input[:interface] = interface updated_at = Time.now ready = false @provider.evaluate(input) do |output, finished| updated_at = Time.now if finished @state[:history] << output self.print(output[:message]) unless streaming - unless Logic::Helpers::Hash.fetch(@cartridge, [:interfaces, mode.to_sym, :postfix]).nil? - self.print(Logic::Helpers::Hash.fetch(@cartridge, [:interfaces, mode.to_sym, :postfix])) - end ready = true flush elsif streaming self.print(output[:message]) end