from .base_memory import BaseMemory from dataclasses import dataclass @dataclass class Task: def __init__(self, name: str, description: str): self.name = name self.description = description class TaskChain: def __init__(self, tasks: list): self.tasks = tasks def append(self, task: Task): self.tasks.append(task) def clear(self): self.tasks = [] def __str__(self): return "\n".join([f"{task.name}: {task.description}" for task in self.tasks]) class PlanMemory(BaseMemory): def __init__(self, initial_message, initial_task) -> None: self.messages = initial_message if initial_message else [] self.tasks = TaskChain(initial_task) if initial_task else TaskChain([]) def append(self, message: str) -> None: self.messages.append(message) #todo: parse message for tasks & add to task chain self.tasks.append(Task("Task", message)) def clear(self) -> None: self.messages = [] def load(self) -> None: pass def save(self) -> None: pass