[BUG] Supabase Setup
Using the same template to query a csv file works with Pinecone but not with Supabase. I get the following error with Supabase:
Error searching for documents: PGRST202 Could not find the function public.CFP(match_count, query_embedding) in the schema cache Searched for the function public.CFP with parameters match_count, query_embedding or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache.
I am attaching a screenshot:
I have triple-checked the Supabase API Key and Project URL. They seem to be OK
Yeah I'm getting some other type of errors with Supabase.. Seems like there is an update needed perhaps?
you'll have to use the pg-vector extension. you can follow the guide here:
1.) Register Supabase account
2.) Dashboard => New Project => SQL Editor => New Query
3.) Copy & Paste queries below and execute:
-- Enable the pgvector extension to work with embedding vectors
create extension vector;
-- Create a table to store your documents
create table documents (
id bigserial primary key,
content text, -- corresponds to Document.pageContent
metadata jsonb, -- corresponds to Document.metadata
embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
);
-- Create a function to search for documents
create function match_documents (
query_embedding vector(1536),
match_count int,
filter jsonb DEFAULT '{}'
) 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 metadata @> filter
order by documents.embedding <=> query_embedding
limit match_count;
end;
$$;
There we go! Thank you! Works like a charm now <3
I have it working now. I also have a couple of comments regarding the "Supabase Upsert Document" module:
- The Supabase API Key corresponds to the "service_role" key
- The Query Name field corresponds to the name of the function, in the code you presented above, the function is "match_documents".
Best.
Jay
I tried everything as described here, documents are being upserted however there is an error: 42883 operator does not exist: extensions.vector <=> extensions.vector null
I couldn't run this command as it said its already installed: "create extension vector;"
Regards
I solved the issue.
@HenryHengZJ and @mgunnin just wanted to say ty. Reading both your comments allowed me to set up a working example. I wish some of that was in official documentation or something tho, cause I was lost for a good while. Anyway, thanks again.
@sunnythaper its now available - https://docs.flowiseai.com/vector-stores/supabase
@HenryHengZJ wow, thank you so much! I hope this saves future users some time! Potentially future me when I try to do this again after a brief hiatus.