Skip to content

Latest commit

 

History

History
123 lines (82 loc) · 3.94 KB

serialization.md

File metadata and controls

123 lines (82 loc) · 3.94 KB

📦 Serialization

Note

COMING SOON! 🚀 Serialization is not yet implemented in Python, but is available today in TypeScript


Overview

Serialization is a process of converting complex data structures or objects (e.g., agents, memories, or tools) into a format that can be easily stored, transmitted, and reconstructed later. Think of it as creating a blueprint of your object that can be used to rebuild it exactly as it was.

BeeAI framework provides robust serialization capabilities through its built-in Serializer class that enables:

  • 💾 Persistence: Store agent state, memory, tools, and other components
  • 🔄 Transmission: Send complex objects across network boundaries or processes
  • 📦 Snapshots: Create point-in-time captures of component state
  • 🔧 Reconstruction: Rebuild objects from their serialized representation
Coming soon

Core Concepts

Serializable Class

Most framework components implement the Serializable class with these key methods:

Method Purpose
createSnapshot() Captures the current state
loadSnapshot(snapshot) Applies a snapshot to the current instance
fromSnapshot(snapshot) Creates a new instance from a snapshot (static)
fromSerialized(data) Creates a new instance from serialized data (static)

Serialization Process

The serialization process involves:

  1. Converting complex objects into a format that preserves their structure and data
  2. Including type information to enable proper reconstruction
  3. Managing references to maintain object identity across serialization boundaries
  4. Handling special cases like circular references and custom types

Basic Usage

Serializing framework components

Most BeeAI components can be serialized out of the box. Here's an example using memory:

Coming soon

[TIP!] Most framework components are Serializable.

Advanced Features

Custom Serialization

If you want to serialize a class that the Serializer does not know, you may register it using one of the following options.

1. Register External Classes

You can register external classes with the serializer:

Coming soon

2. Implement the Serializable Interface

For deeper integration, extend the Serializable class:

Coming soon

[NOTE!] Failure to register a class that the Serializer does not know will result in the SerializerError error. BeeAI framework avoids importing all potential classes automatically to prevent increased application size and unnecessary dependencies.

Context matters

Coming soon

Examples

  • All serialization examples are coming soon in python.