Replies: 4 comments 1 reply
-
🤖 Hello, Based on the information you've provided, it seems you're trying to pass a filter to the const filter = { 'userId': { equals: userId } };
const retriever = vectorStore.asRetriever(undefined, filter); In this example, However, in your case, you're using the Here is an example of how you can do this: const selfQueryRetriever = await SelfQueryRetriever.fromLLM({
llm,
vectorStore,
documentContents,
attributeInfo,
structuredQueryTranslator: new FunctionalTranslator(),
searchParams: {
filter: (doc: Document) => doc.metadata && doc.metadata.userId === userId,
mergeFiltersOperator: "or",
k: docs.length,
},
}); In this example, the filter function includes only documents where the I hope this helps! Let me know if you have any other questions. 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.
-
Unfortunately const filter = { 'userId': { equals: userId } };
const retriever = vectorStore.asRetriever(undefined, filter); this doesn't work :( There are two methods which should get a filter argument and how I think should provide a similar output, but in first case filter doesn't work and it works in second: await vectorStore.similaritySearch("hello world", 3, { userId: { equals: 1 } } ) await vectorStore.similaritySearchWithScore("hello world", 3, { userId: { equals: 1 } } ) I think it could be somehow related to my initial question |
Beta Was this translation helpful? Give feedback.
-
I've encountered the same problem. It appears that the example provided at https://js.langchain.com/docs/integrations/vectorstores/prisma suggests constructing a vector store using the static method withModel, which seems to completely ignore the filter parameter. I managed to get the filter working by constructing the class instance directly and passing the filter like this: const embeddings = new OpenAIEmbeddings()
export const newPrismaVectorStore = (userId: string) => {
return new PrismaVectorStore(embeddings, {
db: prisma,
columns: {
id: PrismaVectorStore.IdColumn,
content: PrismaVectorStore.ContentColumn,
},
prisma: Prisma,
tableName: 'Document',
vectorColumnName: 'vector',
filter: {
user_id: { equals: userId },
},
})
} Additionally, this approach doesn't seem to correctly map the table name/column name if you've used @Map(...) in your Prisma schema. So, in my example, I used user_id instead of userId. I hope this helps |
Beta Was this translation helpful? Give feedback.
-
Created an issue for this: #4521 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to use prisma vectror store as a memory retrieval and have an ability to filter the messages by UserId, like this
await vectorStore.similaritySearchWithScore(input, 3, { userId: { equals: userId } })
. When I'm trying to pass such a filter to asRetriever method, I see no success, what I'm doing wrong?Beta Was this translation helpful? Give feedback.
All reactions