Replies: 2 comments 2 replies
-
Answer generated by a 🤖 AnswerI understand that you've added an Here's a potential solution: You can modify your Here's how you can modify your function: -- Create a function to search for documents
create function match_documents (
query_embedding vector(1536),
match_count int,
-- owner
document_owner uuid
) returns table (
id bigint,
content text,
metadata jsonb,
similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
return query
select
id,
content,
metadata,
1 - (documents.embedding <=> query_embedding) as similarity
from documents
where owner_sid = document_owner -- only return documents owned by the user
order by documents.embedding <=> query_embedding
limit match_count;
end;
$$; In this modified version of the Please note that this is one potential solution based on the information provided. There might be other ways to achieve the same result depending on your specific use case and setup. If you find this solution helpful and believe it might be useful to others, I encourage you to make a pull request to update the documentation. This way, other users facing the same issue can benefit from your experience. SourcesThis response is meant to be useful, save you time, and share context. 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. |
Beta Was this translation helpful? Give feedback.
-
Answer generated by a 🤖 AnswerI understand that you're working with the LangChain Python framework and have set up a Supabase database with a Here's a potential solution using the import { createClient } from '@supabase/supabase-js'
// Initialize Supabase
const supabaseUrl = process.env.SUPABASE_URL
const supabaseKey = process.env.SUPABASE_SERVICE_KEY
const supabase = createClient(supabaseUrl, supabaseKey)
// Get the current user
const user = supabase.auth.user()
// If there's a logged in user
if (user) {
// Get the user's sid
const sid = user.id
// Query the database
const { data, error } = await supabase
.rpc('match_documents', { query_embedding: yourEmbedding, match_count: yourMatchCount, document_owner: sid })
// Handle the response
if (error) {
console.error('Error:', error.message)
} else {
console.log('Matched documents:', data)
}
} In this code, replace Please note that if there's no logged-in user, This is just one potential solution. If you find it helpful and think it might be useful to others, consider making a pull request to update the documentation. This could be a great way to contribute to the LangChain community. SourcesThis response is meant to be useful, save you time, and share context. 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. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I added
owner_sid
to thedocuments
table to determine the ownership of documents by users and only allow users withsid
(uuid) to query their own documents. Here is the SQL snippet I have customized. I am unsure how to pass the usersid
when'embedding'
and'querying'
though.Beta Was this translation helpful? Give feedback.
All reactions