Spaces:
Sleeping
Sleeping
File size: 505 Bytes
df9db76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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 = [] |