Builder
Public builder exports for gllm-memory.
This package exposes the public memory-client factory functions and the
MemoryManagerConfig builder API. The concrete builder implementation lives
under gllm_memory.builder.memory_manager.
MemoryManagerConfig(config, backend_key=MemoryProviderType.MEM0, backend_options=None)
Represent one immutable configuration payload for MemoryManager.
Attributes:
| Name | Type | Description |
|---|---|---|
_config |
dict[str, Any]
|
Core memory-engine configuration payload. |
_backend_key |
str
|
Internal backend key selected for the config. |
_backend_options |
dict[str, Any]
|
Backend-specific auxiliary options. |
Initializes a new instance of the MemoryManagerConfig class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any]
|
Underlying memory-engine config payload. |
required |
backend_key
|
str
|
Internal backend key selected by the library.
Defaults to |
MEM0
|
backend_options
|
dict[str, Any] | None
|
Internal backend-specific options. Defaults to None. |
None
|
builder()
classmethod
Create a fluent builder for MemoryManagerConfig.
Returns:
| Name | Type | Description |
|---|---|---|
MemoryManagerConfigBuilder |
MemoryManagerConfigBuilder
|
New builder instance. |
get_backend_key()
Return the internal backend key selected for this config object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Internal backend key. |
get_backend_options()
Return a safe copy of the backend-specific options.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Cloned backend-specific options. |
to_dict()
Return a safe copy of the core config payload.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Cloned core config payload. |
MemoryManagerConfigBuilder()
Builder for MemoryManagerConfig.
Attributes:
| Name | Type | Description |
|---|---|---|
memory_store |
MemoryManagerStoreBuilder
|
Memory-store configuration helper. |
embedding |
MemoryManagerEmbeddingBuilder
|
Embedding configuration helper. |
llm |
MemoryManagerLLMBuilder
|
LLM registration helper. |
reranker |
MemoryManagerRerankerBuilder
|
Optional reranker configuration helper. |
knowledge_graph |
MemoryManagerKnowledgeGraphBuilder
|
Optional KG configuration helper. |
Initializes a new instance of the MemoryManagerConfigBuilder class.
Returns:
| Type | Description |
|---|---|
None
|
None |
build()
Build one MemoryManagerConfig object from the assembled config.
Returns:
| Name | Type | Description |
|---|---|---|
MemoryManagerConfig |
MemoryManagerConfig
|
Built config object. |
build_config()
Build validated memory-engine config.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Deep-copied config dictionary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required sections are missing. |
conversation_store_path(conversation_store_path)
Set the path used for local conversation-state persistence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_store_path
|
str
|
Local conversation-store path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MemoryManagerConfigBuilder |
MemoryManagerConfigBuilder
|
The builder itself. |
merge_backend_option(key, value)
Merge one nested backend option payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Backend option key. |
required |
value
|
dict[str, Any]
|
Partial backend option payload. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MemoryManagerConfigBuilder |
MemoryManagerConfigBuilder
|
The builder itself. |
set_backend_option(key, value)
Set one backend option payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Backend option key. |
required |
value
|
dict[str, Any]
|
Backend option payload. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MemoryManagerConfigBuilder |
MemoryManagerConfigBuilder
|
The builder itself. |
set_provider_config(section, provider, config)
Set one provider section in the underlying config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
str
|
Section name such as |
required |
provider
|
str
|
Provider identifier. |
required |
config
|
dict[str, Any]
|
Provider config payload. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MemoryManagerConfigBuilder |
MemoryManagerConfigBuilder
|
The builder itself. |
Neo4jGraphStoreConfig(uri, user, password, max_connection_pool_size=DEFAULTS.knowledge_graph_neo4j_max_connection_pool_size)
dataclass
Represent one caller-facing Neo4j graph-store config.
Attributes:
| Name | Type | Description |
|---|---|---|
uri |
str
|
Neo4j connection URI. |
user |
str
|
Neo4j username. |
password |
str
|
Neo4j password. |
max_connection_pool_size |
int
|
Maximum Neo4j connection pool size. |
to_config_dict()
Convert one config object into a plain Neo4j config payload.
Returns:
| Type | Description |
|---|---|
dict[str, str | int]
|
dict[str, str | int]: Plain Neo4j config payload. |
build_from_env(api_key=None, instruction=None, host=None, config=None)
Create a memory client from configuration.
Routes to the appropriate client based on what's provided: 1. If config provided -> resolve internal configured backend 2. Else if api_key or host provided -> Mem0Client (existing) 3. Else read from environment -> Mem0Client (existing)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
API key for authentication. If None, will be read from MEM0_API_KEY environment variable. Defaults to None. |
None
|
instruction
|
str | None
|
Custom instructions for memory handling. Defaults to None. |
None
|
host
|
str | None
|
Host for the memory client. Defaults to None. |
None
|
config
|
dict[str, Any] | MemoryManagerConfig | None
|
Configured memory payload or config object. If provided, resolves the configured backend path. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
BaseMemoryClient |
BaseMemoryClient
|
The created memory client instance. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If API key is not provided and MEM0_API_KEY environment variable is missing. |
ValueError
|
If the provider specified in environment is not supported. |