Skip to content

Instantly share code, notes, and snippets.

@alnutile
Last active March 13, 2025 14:21
Show Gist options
  • Save alnutile/83b18b871ce0eadc0beafe934f40343c to your computer and use it in GitHub Desktop.
Save alnutile/83b18b871ce0eadc0beafe934f40343c to your computer and use it in GitHub Desktop.
Getting supabase setup with flowise
-- 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