🎉 ai-infra v1.0 is here — Production-ready AI/LLM infrastructure
What's new
nfrax logonfrax

Infrastructure that just works. Ship products, not boilerplate.

Frameworks

  • svc-infra
  • ai-infra
  • fin-infra
  • robo-infra

Resources

  • Getting Started
  • What's New
  • Contributing

Community

  • GitHub

© 2026 nfrax. All rights reserved.

nfrax logonfrax
Start HereWhat's New
GitHub
ai-infra / API Reference

MemoryStore

from ai_infra.llm.memory import MemoryStore
View source
ai_infra.llm.memory

Long-term memory store with semantic search. Provides a simple interface for storing and retrieving memories with optional semantic search capabilities. Supports multiple storage backends: - In-memory (dev/testing) - SQLite (single-instance) - PostgreSQL (production) Memories are organized by namespace (tuple of strings) and key. Namespaces enable multi-user and multi-tenant storage.

python
from ai_infra.memory import MemoryStore

    # Simple in-memory store
    store = MemoryStore()

    # With semantic search (requires embedding provider)
    store = MemoryStore(
        embedding_provider="openai",
        embedding_model="text-embedding-3-small",
    )

    # Store user preferences
    store.put(
        namespace=("user_123", "preferences"),
        key="language",
        value={"preference": "User prefers Python"},
    )

    # Search memories
    results = store.search(
        ("user_123", "preferences"),
        query="what programming language",
        limit=5,
    )
Constructor
MemoryStore(backend: str = 'memory', embedding_provider: str | None = None, embedding_model: str | None = None, connection_string: str | None = None, path: str | None = None)
ParameterTypeDefaultDescription
backendstr'memory'Storage backend ("memory", "sqlite", "postgres")
embedding_providerstr|NoneNoneProvider for semantic search (e.g., "openai", "huggingface")
embedding_modelstr|NoneNoneModel for embeddings (e.g., "text-embedding-3-small")
connection_stringstr|NoneNonePostgreSQL connection string (for postgres backend)
pathstr|NoneNoneFile path (for sqlite backend)

Methods

On This Page

Constructordeletegetget_app_memoryget_user_memorylistpostgresclassmethodputput_app_memoryput_user_memorysearchsearch_app_memoriessearch_user_memoriessqliteclassmethod