11Supabase Bridge
22===============
33
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.
55
66.. note ::
77
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.
1510
1611Requirements
1712~~~~~~~~~~~~
1813
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.
2219
2320Database Setup
2421--------------
@@ -39,7 +36,7 @@ Create the `documents` table
3936
4037 CREATE TABLE IF NOT EXISTS documents (
4138 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
42- embedding vector(1536 ) NOT NULL,
39+ embedding vector(768 ) NOT NULL,
4340 metadata JSONB
4441 );
4542
@@ -49,7 +46,7 @@ Create the similarity search function
4946.. code-block :: sql
5047
5148 CREATE OR REPLACE FUNCTION match_documents(
52- query_embedding vector(1536 ),
49+ query_embedding vector(768 ),
5350 match_count int DEFAULT 10,
5451 match_threshold float DEFAULT 0.0
5552 )
@@ -97,7 +94,7 @@ Basic Configuration
9794 'your-anon-key',
9895 'documents', // table name
9996 'embedding', // vector field name
100- 1536 , // vector dimension
97+ 768 , // vector dimension (depending on your embedding model)
10198 'match_documents' // function name
10299 );
103100
@@ -115,7 +112,7 @@ Bundle Configuration
115112 api_key : ' %env(SUPABASE_API_KEY)%'
116113 table : ' documents'
117114 vector_field : ' embedding'
118- vector_dimension : 1536
115+ vector_dimension : 768
119116 function_name : ' match_documents'
120117
121118 Environment Variables
@@ -142,7 +139,7 @@ Adding Documents
142139
143140 $document = new VectorDocument(
144141 Uuid::v4(),
145- new Vector([0.1, 0.2, 0.3, /* ... 1536 dimensions */]),
142+ new Vector([0.1, 0.2, 0.3, /* ... 768 dimensions */]),
146143 new Metadata(['title' => 'My Document', 'category' => 'example'])
147144 );
148145
@@ -153,7 +150,7 @@ Querying Documents
153150
154151.. code-block :: php
155152
156- $queryVector = new Vector([0.1, 0.2, 0.3, /* ... 1536 dimensions */]);
153+ $queryVector = new Vector([0.1, 0.2, 0.3, /* ... 768 dimensions */]);
157154
158155 $results = $store->query($queryVector, [
159156 'max_items' => 10,
@@ -184,7 +181,7 @@ Change ``embedding`` to your preferred field name in both the SQL setup and conf
184181Vector Dimension
185182~~~~~~~~~~~~~~~~
186183
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.
188185
189186Distance Metric
190187~~~~~~~~~~~~~~~
@@ -223,9 +220,7 @@ Security Considerations
223220* Validate vector dimensions in your application code
224221* Implement proper error handling for API failures
225222
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