Last active
March 13, 2025 14:21
-
-
Save alnutile/83b18b871ce0eadc0beafe934f40343c to your computer and use it in GitHub Desktop.
Getting supabase setup with flowise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Enable the pgvector extension to work with embedding vectors | |
create extension vector; | |
-- Create a table to store your documents | |
create table documents ( | |
id text primary key, -- CHANGE TO TEXT | |
content text, | |
metadata jsonb, | |
embedding vector(1536) | |
); | |
-- Create a function to search for documents | |
create function match_documents ( | |
query_embedding vector(1536), | |
match_count int DEFAULT null, | |
filter jsonb DEFAULT '{}' | |
) returns table ( | |
id text, -- CHANGE TO TEXT | |
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; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment