langchain-ai / langchain-template-supabase

MIT License
497 stars 55 forks source link

Add extra filtering to vectorStore? #4

Open santiarias opened 1 year ago

santiarias commented 1 year ago

I want to add userId to documents table so vectorStore only retrieves documents for that userId, any ideas?

DzIGIBAUER commented 1 year ago

I think you can achieve that by using setting up row level security. Add new RLS to your documents table with following USING and WHERE expression:

((auth.uid())::text = (metadata ->> 'user'::text))

and my metadata contains user field with users uuid

metadata: {
   'user': 'e1965a54-4760-4....'
}
santiarias commented 1 year ago

Thanks yeah that is my plan too.

mirko314 commented 1 year ago

I'm also searching for a solution to this. I want to allow users to further narrow down what documents they want to search over. I could not find any existing way for this in the current supabase VectorStore implementation here. I guess one would need to raise a PR in the langchain main repo for this?

nfcampos commented 1 year ago

Hi, there is an open PR in the main repo enabling this which we plan to merge and release soon https://github.com/hwchase17/langchainjs/pull/905