-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
31 lines (28 loc) · 727 Bytes
/
Copy pathinit.sql
File metadata and controls
31 lines (28 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- Initialize database with pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;
-- Create initial schema
CREATE SCHEMA IF NOT EXISTS super_agentic;
-- Set search path
SET search_path TO super_agentic, public;
-- Create vector similarity search function
CREATE OR REPLACE FUNCTION similarity_search(
query_embedding vector(1536),
match_threshold float,
match_count int
)
RETURNS TABLE(
id int,
content text,
similarity float
)
LANGUAGE sql
AS $$
SELECT
id,
content,
1 - (embedding <=> query_embedding) AS similarity
FROM memories
WHERE 1 - (embedding <=> query_embedding) > match_threshold
ORDER BY embedding <=> query_embedding
LIMIT match_count;
$$;