tai / memory_handler.py
shamimjony1000's picture
Upload 8 files
df9db76 verified
raw
history blame contribute delete
505 Bytes
class MemoryHandler:
def __init__(self):
self.conversation_history = []
self.max_history = 5 # Keep last 5 interactions
def add_interaction(self, text):
self.conversation_history.append(text)
if len(self.conversation_history) > self.max_history:
self.conversation_history.pop(0)
def get_context(self):
return " ".join(self.conversation_history)
def clear_memory(self):
self.conversation_history = []