mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-23 21:22:35 +03:00
Add missing sql
This commit is contained in:
parent
c38265a5f5
commit
fcb108808a
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,7 +4,7 @@ secondbrain/
|
||||
**/*.pyc
|
||||
toto.txt
|
||||
*.ipynb
|
||||
|
||||
log.txt
|
||||
|
||||
|
||||
|
||||
|
@ -95,6 +95,8 @@ cp .frontend_env.example frontend/.env
|
||||
|
||||
[Migration Script 2](scripts/supabase_usage_table.sql)
|
||||
|
||||
[Migration Script 3](scripts/supabase_vector_store_summary.sql)
|
||||
|
||||
- **Step 5**: Launch the app
|
||||
|
||||
```bash
|
||||
|
38
scripts/supabase_vector_store_summary.sql
Normal file
38
scripts/supabase_vector_store_summary.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- Create a table to store your summaries
|
||||
create table if not exists summaries (
|
||||
id bigserial primary key,
|
||||
document_id bigint references documents(id),
|
||||
content text, -- corresponds to the summarized content
|
||||
metadata jsonb, -- corresponds to Document.metadata
|
||||
embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION match_summaries(query_embedding vector(1536), match_count int, match_threshold float)
|
||||
RETURNS TABLE(
|
||||
id bigint,
|
||||
document_id bigint,
|
||||
content text,
|
||||
metadata jsonb,
|
||||
-- we return matched vectors to enable maximal marginal relevance searches
|
||||
embedding vector(1536),
|
||||
similarity float)
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
# variable_conflict use_column
|
||||
BEGIN
|
||||
RETURN query
|
||||
SELECT
|
||||
id,
|
||||
document_id,
|
||||
content,
|
||||
metadata,
|
||||
embedding,
|
||||
1 -(summaries.embedding <=> query_embedding) AS similarity
|
||||
FROM
|
||||
summaries
|
||||
WHERE 1 - (summaries.embedding <=> query_embedding) > match_threshold
|
||||
ORDER BY
|
||||
summaries.embedding <=> query_embedding
|
||||
LIMIT match_count;
|
||||
END;
|
||||
$$;
|
Loading…
Reference in New Issue
Block a user