[help] how to force a filter on a createVectorQueryTool (pgVector)
hello,
I have a context with some variables and I would like to force a filter on the query tool
in the context, I set a clientId var and in the pgVector table, I also have a clientId field in metadata col
maybe I'm going in the wrong way and one table / client is a better option ?
how to do it ? I tried to adapt the doc here https://mastra.ai/en/reference/tools/vector-query-tool#example-using-runtime-context without success.
Reference: createVectorQueryTool() | RAG | Mastra Tools Docs
Documentation for the Vector Query Tool in Mastra, which facilitates semantic search over vector stores with filtering and reranking capabilities.
3 Replies
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8970
GitHub
[DISCORD:1428698675420332042] [help] how to force a filter on a cre...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1428698675420332042 hello, I have a context with some variables and I would like to force a filter on the ...
Is this dynamic? Do you want to always filter on clientId?
You can set the
filter
field in RuntimeContext and if passed to your vectoryQueryTool will use that as the filter, otherwise it is what the agent has decided to call.
@mastra/rag also exports vector prompts that help your agent query the store and provide accurate filters
https://github.com/mastra-ai/mastra/blob/main/stores/pg/src/vector/prompt.tsGitHub
mastra/stores/pg/src/vector/prompt.ts at main · mastra-ai/mastra
The TypeScript AI agent framework. ⚡ Assistants, RAG, observability. Supports any LLM: GPT-4, Claude, Gemini, Llama. - mastra-ai/mastra
it's dynamic, and yes I want to filter on clientId
does filter runtimeContext works with pgvector? my tests were not succesful
is relying entirely on the LLM with the pgvector prompt with an instruction passed in the prompt (eg. "always apply filter + runtime context) ok ?