Ruby/memory_buffer.py

12 lines
304 B
Python

from collections import deque
class MemoryBuffer:
def __init__(self, capacity=10):
self.buffer = deque(maxlen=capacity)
def add_interaction(self, user_input, bot_response):
self.buffer.append((user_input, bot_response))
def get_data(self):
return list(self.buffer)