Skip to main content

A memory architecture for AI agents supporting hierarchical and multimodal data.

Project description

Dali Store

Introduction

Dali Store is a sophisticated memory architecture designed for AI agents to efficiently store and retrieve hierarchical memory units, such as tasks, subtasks, steps, and actions. It provides a flexible SDK for managing memory structures without the need to modify underlying database schemas. dali Store leverages both textual and multimodal data, supporting features like similarity search and hierarchical data retrieval.

Features

  • Flexible hierarchical memory storage
  • Multimodal embeddings (text and media)
  • Similarity search across memory units
  • Twin database approach using SQLite and Qdrant
  • Model management with support for text and CLIP models

SDK Overview

The main components of the Dali Store SDK are:

  1. MemoryBankFactory: Factory class to create the appropriate memory bank.
  2. TextMemoryBank: For storing and retrieving text-based memories.
  3. MultimodalMemoryBank: For storing and retrieving multimodal (text + image) memories.

Usage

Initializing the Memory Bank

from dalistore.memory_bank_factory import MemoryBankFactory
factory = MemoryBankFactory()

Using the Text Memory Store

# Create a text memory unit: except for the type, all fields are optional
text_data = {
    'type': 'task',
    'description': 'This is a task memory',
    'metadata': {'key': 'value'},
    'state_before': 'initial_state',
    'state_after': 'final_state',
    'status': 'in_progress',
    'human_comment': 'Human observation',
    'ai_comment': 'AI analysis',
    'parent_id': 'parent_task_id'
}

# Get the appropriate memory bank (default is text)
memory_bank = factory.get_memory_bank()

# Store the memory unit
unique_id = memory_bank.store(text_data)

# Embed the memory unit
memory_bank.embed(unique_id, text_data)

# Retrieve the memory unit
retrieved_data = memory_bank.retrieve_by_id(unique_id)

#Search similar units
query = {
    'description': 'text memory',
    'human_comment': 'observation'
}
similar_ids = memory_bank.retrieve_similar(query, max_results=5)

# Edit the memory unit
edit_data = {'description': 'Updated text memory'}
memory_bank.edit(unique_id, edit_data)

# Delete the memory unit
memory_bank.delete(unique_id)

# Close the memory bank
memory_bank.close()

Using the Multimodal Memory Store

from PIL import Image
from datetime import datetime

# Create a multimodal memory unit: except for the type, all fields are optional
multimodal_data = {
    'type': 'subtask',
    'description': 'This is a subtask memory',
    'metadata': {'key': 'value'},
    'state_before': Image.new('RGB', (100, 100), color='red'),
    'state_after': Image.new('RGB', (100, 100), color='green'),
    'status': 'in_progress',
    'human_comment': 'Human observation of image',
    'ai_comment': 'AI analysis of image',
    'media_blobs': [
        {
            'id': 'image_' + datetime.now().strftime('%Y%m%d%H%M%S'),
            'media_data': Image.new('RGB', (100, 100), color='yellow'),
            'media_type': 'image'
        }
    ]
}

# Get the appropriate memory bank
memory_bank = factory.get_memory_bank(multimodal=True)

# Store the memory unit
unique_id = memory_bank.store(multimodal_data)

# Embed the memory unit
memory_bank.embed(unique_id, multimodal_data)

# Retrieve the memory unit
retrieved_data = memory_bank.retrieve_by_id(unique_id)

# Search for similar memories by text
similar_ids = memory_bank.retrieve_similar({'description': 'multimodal memory'}, max_results=5)

# Search for similar memories by image
query_image = Image.new('RGB', (100, 100), color='red')
similar_ids = memory_bank.retrieve_similar({'state_before': query_image}, max_results=5)

# Search using multiple fields
query = {
    'description': 'multimodal memory',
    'human_comment': 'observation of image'
}
similar_ids = memory_bank.retrieve_similar(query, max_results=5)

# Edit the memory unit
edit_data = {'description': 'Updated multimodal memory'}
memory_bank.edit(unique_id, edit_data)

# Delete the memory unit
memory_bank.delete(unique_id)

# Close the memory bank
memory_bank.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dalistore-0.1.7.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

dalistore-0.1.7-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file dalistore-0.1.7.tar.gz.

File metadata

  • Download URL: dalistore-0.1.7.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for dalistore-0.1.7.tar.gz
Algorithm Hash digest
SHA256 24f5c266db8f3445d9be490a80ceb032b0caa0e5b9bab6437a69fd8c8b7b66de
MD5 53ac6b892cbe0d022dfd8904a3f65743
BLAKE2b-256 b02bf27f539a65a2f8353e0d07164a8b393d7b167c99ad8a7d45a6a5fe7ab2d9

See more details on using hashes here.

File details

Details for the file dalistore-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: dalistore-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for dalistore-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c65921f57c29f129a7eacb09ee01b7dd403d516081573c4e4e891bd6482bd03b
MD5 245aca6c8f961997946dc1dba69df700
BLAKE2b-256 de7a26caf540c98d3b79fb0ed27196b9cd8036d5df69c66d5c59bdd55cdbff4e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page