Searching and storing metadata with the VectorStoreRetrieverMemory memory module #3107
Replies: 2 comments 6 replies
-
🤖 Hello @frankolson, I'm here to assist you with your question about the To save metadata or prevent the module from saving so you can implement a custom saving method, you can extend the class CustomVectorStoreRetrieverMemory extends VectorStoreRetrieverMemory {
async saveContext(inputValues: InputValues, outputValues: OutputValues): Promise<void> {
// Your custom saving logic here
}
} This will allow you to control how the context is saved, including whether or not metadata is saved. If you want to prevent saving entirely, you could leave the class CustomVectorStoreRetrieverMemory extends VectorStoreRetrieverMemory {
async saveContext(inputValues: InputValues, outputValues: OutputValues): Promise<void> {
// Do nothing
}
} This would effectively prevent the context from being saved. The metadata that needs to be saved along with the context is structured as a string. This string is constructed by joining the key-value pairs of the input and output values (excluding the memory key), with each pair formatted as I hope this helps! If you have any other questions or need further clarification, feel free to ask. Best, Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
I'm also missing this feature. As you've shown the filtering can be done on the vectorstore itself, but the storing cannot. There's really 2 options to have this work:
The first options shouldn't take much to implement, but I don't see a way to easily filter results from an existing retriever, so if that should be possible |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is my example code for using a vector store as memory and providing metadata filters:
In the code I am using
excludedIds
to filter out certain messages, but it could also be used to scope loops to just those with a specific userId. What I want to do is look up messages with these filters, but then also save the current message with it's own metadata (eg. message IDs, userIDs, etc.). However, theVectorStoreRetrieverMemory
will save conversations using the internalsaveContext
function which doesn't provide a way for adding documents with metadata (source link):How do I use the save metadata while using the
VectorStoreRetrieverMemory
memory module or prevent it from saving (making it exclusively a lookup module) so that I can implement my own custom saving method?Beta Was this translation helpful? Give feedback.
All reactions