Module: Luo::Middleware::MemoryHistory

Extended by:
MemoryHistory
Included in:
MemoryHistory
Defined in:
lib/luo/middleware/memory_history.rb

Instance Method Summary collapse

Instance Method Details

#create(history) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/luo/middleware/memory_history.rb', line 8

def create(history)
  Class.new(Base) do
    @history = history
    def initialize(app)
      @app = app
    end

    before do |env|
      env.set(:history, @history)
    end

    after do |env|
      @history.user env.fetch(:input)
      @history.assistant env.fetch(:output)
    end

  end
end