Skip to content

Commit

Permalink
Fix wrong id type on db function
Browse files Browse the repository at this point in the history
  • Loading branch information
0ptim committed Jul 16, 2023
1 parent 2a4032c commit 84cd2a4
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
drop function if exists match_embeddings(vector(1536), int, jsonb);

-- Create a function to search for embeddings
create function match_embeddings (
query_embedding vector(1536),
match_count int default null,
filter jsonb DEFAULT '{}'
) returns table (
id uuid,
content text,
metadata jsonb,
similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
return query
select
id,
content,
metadata,
1 - (embeddings.embedding <=> query_embedding) as similarity
from embeddings
where metadata @> filter
order by embeddings.embedding <=> query_embedding
limit match_count;
end;
$$;

0 comments on commit 84cd2a4

Please sign in to comment.