Storage API

Setting Up Storage Layer

The SDK provides a dedicated method to configure and initialize storage components through the add_storage_layer method. This setup is essential for managing data persistence and retrieval operations:

def add_storage_layer(self, config: StorageLayer) -> 'Cerebrum':
    """Set up the storage component."""
    result = self._post("/core/storage/setup", asdict(config))
    self._components_initialized.add("storage")
    self.results['storage'] = result
    return self

This method handles storage setup by communicating with the /core/storage/setup endpoint, which is processed by the kernel for initialization and configuration.

Storage Configuration

The StorageLayer class defines the essential parameters for storage configuration:

@dataclass
class StorageLayer:
    root_dir: str = "root"            # Root directory for storage operations
    use_vector_db: bool = False       # Toggle vector database functionality
    vector_db_config: Optional[Dict[str, Any]] = None  # Vector database configuration settings

Key Components:

  • root_dir: Specifies the base directory for all storage operations

  • use_vector_db: Enables or disables vector database functionality

  • vector_db_config: Optional configuration for vector database settings when enabled

Storage Operations

Interactions with the storage layer are handled through the StorageQuery class:

class StorageQuery(BaseModel):
    messages: List[Dict[str, Union[str, Any]]]  # Message content list
    operation_type: str = Field(default="text")  # Operation type specification

    class Config:
        arbitrary_types_allowed = True  # Enables complex type usage

Query Parameters

  • messages: Contains a list of message dictionaries with content for storage operations

  • operation_type: Specifies the type of storage operation to perform

Last updated