Skip to main content

Memory components in Langflow

Memory components store and retrieve chat messages by session_id.

They are distinct from vector store components, because they are built specifically for storing and retrieving chat messages from external databases.

Memory components provide access to their respective external databases as memory. This allows Large Language Models (LLMs) or agents to access external memory for persistence and context retention.

Use a memory component in a flow

This example flow stores and retrieves chat history from an Astra DB Chat Memory component with Store Message and Message history components.

The Store Message helper component stores chat memories as Data objects, and the Message History helper component retrieves chat messages as Data objects or strings.

Sample Flow storing Message history in AstraDB

AstraDBChatMemory Component

This component creates an AstraDBChatMessageHistory instance, which stores and retrieves chat messages using Astra DB, a cloud-native database service.

Parameters

Inputs

NameTypeDescription
collection_nameStringThe name of the Astra DB collection for storing messages. Required.
tokenSecretStringThe authentication token for Astra DB access. Required.
api_endpointSecretStringThe API endpoint URL for the Astra DB service. Required.
namespaceStringThe optional namespace within Astra DB for the collection.
session_idMessageTextThe chat session ID. Uses the current session ID if not provided.

Outputs

NameTypeDescription
message_historyBaseChatMessageHistoryAn instance of AstraDBChatMessageHistory for the session.

CassandraChatMemory Component

This component creates a CassandraChatMessageHistory instance, enabling storage and retrieval of chat messages using Apache Cassandra or DataStax Astra DB.

Parameters

Inputs

NameTypeDescription
database_refMessageTextThe contact points for the Cassandra database or Astra DB database ID. Required.
usernameMessageTextThe username for Cassandra. Leave empty for Astra DB.
tokenSecretStringThe password for Cassandra or the token for Astra DB. Required.
keyspaceMessageTextThe keyspace in Cassandra or namespace in Astra DB. Required.
table_nameMessageTextThe name of the table or collection for storing messages. Required.
session_idMessageTextThe unique identifier for the chat session. Optional.
cluster_kwargsDictionaryAdditional keyword arguments for the Cassandra cluster configuration. Optional.

Outputs

NameTypeDescription
message_historyBaseChatMessageHistoryAn instance of CassandraChatMessageHistory for the session.

Mem0 Chat Memory

The Mem0 Chat Memory component retrieves and stores chat messages using Mem0 memory storage.

Parameters

Inputs

NameDisplay NameInfo
mem0_configMem0 ConfigurationThe configuration dictionary for initializing the Mem0 memory instance.
ingest_messageMessage to IngestThe message content to be ingested into Mem0 memory.
existing_memoryExisting Memory InstanceAn optional existing Mem0 memory instance.
user_idUser IDThe identifier for the user associated with the messages.
search_querySearch QueryThe input text for searching related memories in Mem0.
mem0_api_keyMem0 API KeyThe API key for the Mem0 platform. Leave empty to use the local version.
metadataMetadataThe additional metadata to associate with the ingested message.
openai_api_keyOpenAI API KeyThe API key for OpenAI. Required when using OpenAI embeddings without a provided configuration.

Outputs

NameDisplay NameInfo
memoryMem0 MemoryThe resulting Mem0 Memory object after ingesting data.
search_resultsSearch ResultsThe search results from querying Mem0 memory.

Redis Chat Memory

This component retrieves and stores chat messages from Redis.

Parameters

Inputs

NameDisplay NameInfo
hosthostnameThe IP address or hostname.
portportThe Redis Port Number.
databasedatabaseThe Redis database.
usernameUsernameThe Redis username.
passwordPasswordThe password for the username.
key_prefixKey prefixThe key prefix.
session_idSession IDThe session ID for the message.

Outputs

NameDisplay NameInfo
memoryMemoryThe Redis chat message history object.

Legacy components

Legacy components are available for use but are no longer supported.

ZepChatMemory Component

This component creates a ZepChatMessageHistory instance, enabling storage and retrieval of chat messages using Zep, a memory server for Large Language Models (LLMs).

Parameters

Inputs

NameTypeDescription
urlMessageTextThe URL of the Zep instance. Required.
api_keySecretStringThe API Key for authentication with the Zep instance.
api_base_pathDropdownThe API version to use. Options include api/v1 or api/v2.
session_idMessageTextThe unique identifier for the chat session. Optional.

Outputs

NameTypeDescription
message_historyBaseChatMessageHistoryAn instance of ZepChatMessageHistory for the session.
Search