Configuring MemMachine
MemMachine has two primary files that are required for operation:config.yaml
- This file contains the configuration settings for MemMachine’s Episodic Memory, including database connections, model settings, and memory parameters..env
- This file is used to store environment variables for the MemMachine Server Configuration, such as API keys and sensitive information that should not be hardcoded in the configuration file.
Episodic Memory Configuration (config.yaml
)
Understanding Configuration Settings
You can customize your application’s settings with two types of configuration: Global and Local.
- Global Configuration acts as the default setting for all your applications. Think of it as your standard setup that everything uses unless told otherwise. This file should reside in your Project root directory.
- Local Configuration is used when you need to make specific, one-time adjustments for a single session or task. This is best for situations where you have multiple agents, and wish to configure each agent differently. The file should reside in the root directory for each individual agent.
Tailor MemMachine to Your Needs
Check out the following configuration options, an example of how to set, where to set, and a link to more information about the variable options.Long-Term Memory
Parameters that pertain to Long-Term memory settings.Parameter | Required? | Default | Description |
---|---|---|---|
derivative_deriver | No | sentence | Sets the method for deriving new, insightful information from a memory’s content (can choose identity or sentence ). |
metadata_derivative_format | No | N/A | A template string for formatting derived metadata from memory content. Uses bracket notation to pull properties like user_metadata[source_timestamp] and isolation_properties[producer_id] . |
embedder | No | N/A | The ID of the embedder model to use for generating vector embeddings for long-term memory. |
reranker | No | N/A | The ID of the reranker to use for reordering search results to improve relevance. |
vector_graph_store | No | N/A | The ID of the storage vendor to use for long-term memory and vector graph storage. |
Session Memory
Parameter | Required? | Default | Description |
---|---|---|---|
model_name | No | N/A | The ID of the model to use for session memory. |
message_capacity | No | 500 | The maximum number of messages to store in session memory. |
max_message_length | No | 16000 | The maximum length of a message in session memory. |
max_token_num | No | 8000 | The maximum number of tokens to store in session memory. |
Sessiondb
Parameter | Required? | Default | Description |
---|---|---|---|
uri | Yes | sqlitetest.db | The connection URI for the session database. Defaults to an in-memory SQLite database for testing. |
LLM Model
The LLM Model to be used with the memory system.Parameter | Required? | Default | Description |
---|---|---|---|
<ID>.model_name | Yes | N/A | The name of a large language model to use (e.g., gpt-4o-mini ). |
<ID>.api_key | No | N/A | The API key for the specified model. |
Storage
The Storage database that can be chosen for our Memory to use. Only graph database is supported at this time
Parameter | Required? | Default | Description |
---|---|---|---|
<ID>.vendor_name | No | neo4j | The name of the database vendor to use (e.g., neo4j ). |
<ID>.host | No | localhost | The hostname or IP address of the database server. |
<ID>.port | No | 7687 | The port number for the database connection. |
<ID>.user | No | N/A | The username for database authentication. |
<ID>.password | No | N/A | The password for database authentication. |
Embedder
The Embedder model that we choose to use.Parameter | Required? | Default | Description |
---|---|---|---|
<ID>.model_vendor | Yes | N/A | The name of an embedding model to use (e.g., text-embedding-3-small ). |
<ID>.api_key | No | N/A | The API key for the specified embedding model. |
<ID>.type | No | N/A | The type of reranker (e.g., rrf-hybrid , identity , bm25 , cross-encoder ). |
<ID>.reranker_ids | No | N/A | A list of other reranker IDs to combine for hybrid reranking. |
<ID>.model_name | Yes | N/A | The name of a model to use for cross-encoder reranking (e.g., cross-encoder/qnli-electra-base ). |
Reranker
Parameters to set for the chosen RerankerParameter | Required? | Default | Description |
---|---|---|---|
type | Yes | rrf-hybrid | The type of reranker you choose to use. |
Example Config.YAML File
Below is a complete example of theConfig.YAML
file that you can use for default settings when deploying MemMachine. This example comes with the MemMachine package within the samples
directory.
MemMachine Server Configuration (.env
)
To get the MemMachine Server up and running, we use a simple .env
file to manage configuration settings. This approach keeps sensitive information—like database credentials and service URLs—separate from the core codebase. This guide explains each of the required variables.
File Location:
This file should be saved as .env
and placed in the same directory as your app.py
file.
Reference File:
Variable Definitions
Here is a breakdown of each variable in your.env
file:
POSTGRES_HOST
- Purpose: Specifies the network address (IP address or hostname) of your PostgreSQL database server.
- Example:
"10.0.0.59"
refers to a specific IP on your network.
POSTGRES_PORT
- Purpose: The port number on which the PostgreSQL server is listening for connections. The default port is
5432
. - Example:
"5432"
- Purpose: The port number on which the PostgreSQL server is listening for connections. The default port is
POSTGRES_USER
- Purpose: The username used to authenticate with the PostgreSQL database.
- Example:
"postgres"
POSTGRES_PASS
- Purpose: The password for the specified PostgreSQL user. Important: Replace
"YOUR PASSWORD"
with your actual, secure password. - Example:
"my_s3cr3t_p@ssw0rd"
- Purpose: The password for the specified PostgreSQL user. Important: Replace
POSTGRES_DB
- Purpose: The name of the specific database you want to connect to on the PostgreSQL server.
- Example:
"memmachine_db"
MCP_BASE_URL
- Purpose: The base URL for the Model Content Protocol (MCP) service. This is used for internal communication within your MemMachine services.
- Example:
"http://127.0.0.1:8080"
is a common local development address.
GATEWAY_URL
- Purpose: The URL for the public-facing gateway or reverse proxy that routes traffic to your API.
- Example:
"http://localhost:8080"
FAST_MCP_LOG_LEVEL
- Purpose: Sets the logging level for the Fast MCP module. This controls the verbosity of the log output. Common levels include
INFO
,DEBUG
,WARNING
,ERROR
, andCRITICAL
. - Example:
INFO
provides general information without excessive detail.
- Purpose: Sets the logging level for the Fast MCP module. This controls the verbosity of the log output. Common levels include
MEMORY_CONFIG
- Purpose: This variable should point to the file path of your memory configuration file, which defines how MemMachine’s memory components are structured and initialized.
- Example:
"config/memory_config.yaml"
.env
file, making sure to replace placeholder values with your actual configuration details. The same file is also included in the MemMachine package within the samples
directory.