Interfaces¶
Sync Protocols¶
emotional_memory.interfaces.Embedder
¶
Bases: Protocol
Converts text to a dense vector representation.
emotional_memory.interfaces.MemoryStore
¶
Bases: Protocol
Persistent storage for Memory objects.
emotional_memory.interfaces.AffectiveStateStore
¶
Bases: Protocol
Persistent storage for the current affective state snapshot.
emotional_memory.interfaces.SequentialEmbedder
¶
Base class for Embedder implementations that lack native batching.
Subclass this and implement embed(); embed_batch() is provided
automatically by calling embed() for each item in sequence.
Example::
class MyEmbedder(SequentialEmbedder):
def embed(self, text: str) -> list[float]:
return my_model.encode(text).tolist()
Async Protocols¶
emotional_memory.interfaces_async.AsyncEmbedder
¶
Bases: Protocol
Async variant of the Embedder protocol.
emotional_memory.interfaces_async.AsyncMemoryStore
¶
Bases: Protocol
Async variant of the MemoryStore protocol.
count() replaces __len__ because __len__ cannot be declared
async in Python.
emotional_memory.interfaces_async.AsyncAppraisalEngine
¶
Bases: Protocol
Async variant of the AppraisalEngine protocol.
Async Adapters¶
emotional_memory.async_adapters.SyncToAsyncEmbedder(sync_embedder: Embedder)
¶
emotional_memory.async_adapters.SyncToAsyncStore(sync_store: MemoryStore)
¶
Wraps a synchronous MemoryStore for use with AsyncEmotionalMemory.
Source code in src/emotional_memory/async_adapters.py
close() -> None
async
¶
Proxy close() to the wrapped store if it supports it.
emotional_memory.async_adapters.SyncToAsyncAppraisalEngine(sync_engine: AppraisalEngine)
¶
emotional_memory.async_adapters.as_async(engine: EmotionalMemory) -> AsyncEmotionalMemory
¶
Wrap a synchronous EmotionalMemory into an async one.
All I/O calls (embed, store, appraise) are delegated via
asyncio.to_thread. The engine's affective state is copied at
wrap time — the two engines are independent after this point and their
states diverge as each processes new events. The underlying store and
embedder are shared (same object references), so concurrent writes from
both engines will interleave.