"""
ContextualMemory
Generated by Eden via recursive self-improvement
2025-10-28 08:41:25.938292
"""

class ContextualMemory:
    """
    A capability that allows the AI to maintain and manage contextual memory.
    
    This class provides methods to store context, retrieve context based on keys,
    and clear the memory. It helps in maintaining continuity in conversations by 
    remembering relevant information from past interactions.
    
    Example usage:
        cm = ContextualMemory()
        cm.add_context("user_name", "Alice")
        print(cm.get_context("user_name"))  # Output: 'Alice'
        cm.clear_context()
    """

    def __init__(self):
        """Initialize the contextual memory with an empty dictionary."""
        self.context_store = {}

    def add_context(self, key, value):
        """
        Store a piece of context in the memory.
        
        Args:
            key (str): The identifier for the context.
            value (str): The information to store.
        """
        self.context_store[key] = str(value)

    def get_context(self, key):
        """
        Retrieve a stored piece of context by its key.
        
        Args:
            key (str): The identifier for the context to retrieve.
            
        Returns:
            str: The stored value or an empty string if not found.
        """
        return self.context_store.get(key, "")

    def clear_context(self):
        """Clear all stored contextual information."""
        self.context_store.clear()

    def __repr__(self):
        """String representation of the context store."""
        return f"ContextualMemory: {self.context_store}"