Overview
The Memory Gateway node acts as a filter and transformer for memory content before it is stored or after it is retrieved from an internal memory source such as Postgres or Redis. It is useful in scenarios where you want to preprocess or clean AI conversation data before saving it to memory, or postprocess data after retrieving it, ensuring the stored or retrieved data meets specific formatting or content requirements. For example, it can remove unwanted metadata or tool usage information from AI responses before saving, or modify retrieved chat history messages for further processing.
Use Case Examples
- Cleaning AI response messages by removing tool usage metadata before saving to memory.
- Filtering retrieved chat history messages to remove or modify certain entries before further use.
Properties
| Name | Meaning |
|---|---|
| Internal Memory Connected | Notice to connect one internal memory node (e.g., Postgres, Redis) to the input above. |
| Filter Before Save | JavaScript function to filter and transform data before saving to internal memory. It receives the user input and AI output messages and returns possibly modified versions of these messages. |
| Filter After Retrieve | JavaScript function to filter and transform data after retrieving from internal memory. It receives an array of messages and returns a modified array. |
Output
JSON
action- Indicates the action performed, e.g., 'loadMemoryVariables' or 'saveContext'.chatHistory- The chat history messages after filtering or transformation.
Dependencies
- Requires an internal memory node connection (e.g., Postgres, Redis) as input.
Troubleshooting
- Error 'No internal memory connected!' occurs if no internal memory node is connected to the input. Ensure a compatible memory node is connected.
- Errors in the user-defined JavaScript filter functions (Filter Before Save or Filter After Retrieve) will be logged to the console with a message indicating the error source. Check the syntax and logic of these functions if filtering does not behave as expected.
Links
- Memory Gateway Node Documentation - Primary documentation and source for the Memory Gateway node.