1
1
Supabase Bridge
2
2
===============
3
3
4
- The Supabase bridge provides vector storage capabilities using Supabase's pgvector extension through the REST API.
4
+ The Supabase bridge provides vector storage capabilities using ` pgvector `_ extension through the REST API.
5
5
6
6
.. note ::
7
7
8
- * Unlike the Postgres Store, the Supabase Store requires manual setup of the database schema
9
- * because Supabase doesn't allow arbitrary SQL execution via REST API.
10
-
11
- Installation
12
- ------------
13
-
14
- The Supabase bridge requires the pgvector extension and pre-configured database objects.
8
+ Unlike the Postgres Store, the Supabase Store requires manual setup of the database schema because Supabase doesn't
9
+ allow arbitrary SQL execution via REST API.
15
10
16
11
Requirements
17
12
~~~~~~~~~~~~
18
13
19
- * Supabase project with pgvector extension enabled
20
- * Pre-configured table with vector column
21
- * Pre-configured RPC function for similarity search
14
+ * Enable `pgvector extension `_ in the relevant schema of your Supabase project for using `vector `_ column types.
15
+ * Add columns for embedding (type `vector `) and metadata (type `jsonb `) to your table
16
+ * Pre-configured RPC `function `_ for similarity search
17
+
18
+ See section below for detailed SQL commands.
22
19
23
20
Database Setup
24
21
--------------
@@ -39,7 +36,7 @@ Create the `documents` table
39
36
40
37
CREATE TABLE IF NOT EXISTS documents (
41
38
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
42
- embedding vector(1536 ) NOT NULL,
39
+ embedding vector(768 ) NOT NULL,
43
40
metadata JSONB
44
41
);
45
42
@@ -49,7 +46,7 @@ Create the similarity search function
49
46
.. code-block :: sql
50
47
51
48
CREATE OR REPLACE FUNCTION match_documents(
52
- query_embedding vector(1536 ),
49
+ query_embedding vector(768 ),
53
50
match_count int DEFAULT 10,
54
51
match_threshold float DEFAULT 0.0
55
52
)
@@ -97,7 +94,7 @@ Basic Configuration
97
94
'your-anon-key',
98
95
'documents', // table name
99
96
'embedding', // vector field name
100
- 1536 , // vector dimension
97
+ 768 , // vector dimension (depending on your embedding model)
101
98
'match_documents' // function name
102
99
);
103
100
@@ -115,7 +112,7 @@ Bundle Configuration
115
112
api_key : ' %env(SUPABASE_API_KEY)%'
116
113
table : ' documents'
117
114
vector_field : ' embedding'
118
- vector_dimension : 1536
115
+ vector_dimension : 768
119
116
function_name : ' match_documents'
120
117
121
118
Environment Variables
@@ -142,7 +139,7 @@ Adding Documents
142
139
143
140
$document = new VectorDocument(
144
141
Uuid::v4(),
145
- new Vector([0.1, 0.2, 0.3, /* ... 1536 dimensions */]),
142
+ new Vector([0.1, 0.2, 0.3, /* ... 768 dimensions */]),
146
143
new Metadata(['title' => 'My Document', 'category' => 'example'])
147
144
);
148
145
@@ -153,7 +150,7 @@ Querying Documents
153
150
154
151
.. code-block :: php
155
152
156
- $queryVector = new Vector([0.1, 0.2, 0.3, /* ... 1536 dimensions */]);
153
+ $queryVector = new Vector([0.1, 0.2, 0.3, /* ... 768 dimensions */]);
157
154
158
155
$results = $store->query($queryVector, [
159
156
'max_items' => 10,
@@ -184,7 +181,7 @@ Change ``embedding`` to your preferred field name in both the SQL setup and conf
184
181
Vector Dimension
185
182
~~~~~~~~~~~~~~~~
186
183
187
- Change ``1536 `` to match your embedding model's dimensions in both the SQL setup and configuration.
184
+ Change ``768 `` to match your embedding model's dimensions in both the SQL setup and configuration.
188
185
189
186
Distance Metric
190
187
~~~~~~~~~~~~~~~
@@ -223,9 +220,7 @@ Security Considerations
223
220
* Validate vector dimensions in your application code
224
221
* Implement proper error handling for API failures
225
222
226
- Additional Resources
227
- --------------------
228
-
229
- * [Supabase Vector Documentation](https://supabase.com/docs/guides/ai/vector-columns)
230
- * [pgvector Documentation](https://github.com/pgvector/pgvector)
231
- * [Symfony AI Store Documentation](../../../README.md)
223
+ .. _`pgvector` : https://github.com/pgvector/pgvector
224
+ .. _`pgvector extension` : https://supabase.com/docs/guides/database/extensions/pgvector
225
+ .. _`vector` : https://supabase.com/docs/guides/ai/vector-columns
226
+ .. _`function` : https://supabase.com/docs/guides/database/functions
0 commit comments