symfonic.memory.orchestrator.factory¶
factory ¶
OrchestratorFactory -- DI wiring for MemoryOrchestrator.
Centralises the construction of all internal components from backends and configuration. Uses a layer registry for Open/Closed compliance: new memory layers can be registered without modifying existing code.
HybridBackendConfig
dataclass
¶
HybridBackendConfig(
layer_graph_backends: dict[
MemoryLayer, GraphBackend
] = dict(),
layer_vector_backends: dict[
MemoryLayer, VectorBackend
] = dict(),
layer_embedding_providers: dict[
MemoryLayer, EmbeddingProvider
] = dict(),
)
Per-layer backend overrides for hybrid storage configurations.
Allows routing different memory layers to different backends. For example: episodic -> MongoDB, semantic -> Postgres, working -> in-memory.
Any layer not listed in the override dicts falls back to the defaults
supplied to :meth:OrchestratorFactory.build_hybrid.
OrchestratorFactory ¶
Builds a fully-wired MemoryOrchestrator from configuration and backends.
build
staticmethod
¶
build(
config: OrchestratorConfig,
graph_backend: GraphBackend,
vector_backend: VectorBackend,
embedding_provider: EmbeddingProvider,
llm: Any,
catalog: ToolCatalog | None = None,
) -> MemoryOrchestrator
Wire all internal components from configuration and backends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OrchestratorConfig
|
Orchestrator configuration. |
required |
graph_backend
|
GraphBackend
|
Graph storage backend. |
required |
vector_backend
|
VectorBackend
|
Vector storage backend. |
required |
embedding_provider
|
EmbeddingProvider
|
Text embedding provider. |
required |
llm
|
Any
|
LLM instance (BaseChatModel from langchain-core). |
required |
catalog
|
ToolCatalog | None
|
Optional tool catalog. Creates empty one if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
MemoryOrchestrator
|
Fully wired MemoryOrchestrator instance. |
Source code in src/symfonic/memory/orchestrator/factory.py
build_hybrid
staticmethod
¶
build_hybrid(
config: OrchestratorConfig,
default_graph: GraphBackend,
default_vector: VectorBackend,
default_embedding: EmbeddingProvider,
hybrid: HybridBackendConfig,
llm: Any,
catalog: ToolCatalog | None = None,
) -> MemoryOrchestrator
Build an orchestrator with per-layer backend routing.
For each enabled layer, checks hybrid for an override backend.
Falls back to the supplied defaults for layers without overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OrchestratorConfig
|
Orchestrator configuration. |
required |
default_graph
|
GraphBackend
|
Default graph backend for layers without an override. |
required |
default_vector
|
VectorBackend
|
Default vector backend for layers without an override. |
required |
default_embedding
|
EmbeddingProvider
|
Default embedding provider for layers without an override. |
required |
hybrid
|
HybridBackendConfig
|
Per-layer backend override map. |
required |
llm
|
Any
|
LLM instance (BaseChatModel from langchain-core). |
required |
catalog
|
ToolCatalog | None
|
Optional tool catalog. |
None
|
Returns:
| Type | Description |
|---|---|
MemoryOrchestrator
|
Fully wired MemoryOrchestrator using per-layer routing. |
Source code in src/symfonic/memory/orchestrator/factory.py
from_postgres
staticmethod
¶
from_postgres(
config: OrchestratorConfig,
dsn: str,
embedding_provider: EmbeddingProvider,
llm: Any,
catalog: ToolCatalog | None = None,
min_pool_size: int = 2,
max_pool_size: int = 10,
embedding_dim: int = 1536,
) -> MemoryOrchestrator
Build a fully-wired orchestrator backed by PostgreSQL.
Creates a shared PostgresPoolManager and wires both graph and vector backends from it. Callers are responsible for opening the pool before use and closing it on shutdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OrchestratorConfig
|
Orchestrator configuration. |
required |
dsn
|
str
|
asyncpg-compatible DSN (e.g. |
required |
embedding_provider
|
EmbeddingProvider
|
Text embedding provider. |
required |
llm
|
Any
|
LLM instance (BaseChatModel from langchain-core). |
required |
catalog
|
ToolCatalog | None
|
Optional tool catalog. |
None
|
min_pool_size
|
int
|
Minimum pool connections (default 2). |
2
|
max_pool_size
|
int
|
Maximum pool connections (default 10). |
10
|
embedding_dim
|
int
|
Vector embedding dimensions (default 1536). |
1536
|
Returns:
| Type | Description |
|---|---|
MemoryOrchestrator
|
Fully wired MemoryOrchestrator using PostgreSQL backends. |