Skip to content

Commit b7b01c1

Browse files
committed
patch example, default envs and docs after test
1 parent 0d37568 commit b7b01c1

File tree

4 files changed

+35
-40
lines changed

4 files changed

+35
-40
lines changed

src/store/doc/bridges/supabase.rst renamed to docs/components/store/supabase.rst

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
Supabase 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

1611
Requirements
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

2320
Database 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
184181
Vector 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

189186
Distance 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

examples/.env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ DEEPSEEK_API_KEY=
160160
# Supabase (store)
161161
SUPABASE_URL=
162162
SUPABASE_API_KEY=
163-
SUPABASE_TABLE=
164-
SUPABASE_VECTOR_FIELD=
165-
SUPABASE_VECTOR_DIMENSION=
166-
SUPABASE_MATCH_FUNCTION=
163+
SUPABASE_TABLE=documents
164+
SUPABASE_VECTOR_FIELD=embedding
165+
SUPABASE_VECTOR_DIMENSION=768 # when using Ollama with nomic-embed-text
166+
SUPABASE_MATCH_FUNCTION=match_documents

examples/rag/supabase.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\AI\Agent\Toolbox\Tool\SimilaritySearch;
1515
use Symfony\AI\Agent\Toolbox\Toolbox;
1616
use Symfony\AI\Fixtures\Movies;
17-
use Symfony\AI\Platform\Bridge\Ollama\Ollama;
1817
use Symfony\AI\Platform\Bridge\Ollama\PlatformFactory;
1918
use Symfony\AI\Platform\Message\Message;
2019
use Symfony\AI\Platform\Message\MessageBag;
@@ -32,6 +31,10 @@
3231
httpClient: http_client(),
3332
url: env('SUPABASE_URL'),
3433
apiKey: env('SUPABASE_API_KEY'),
34+
table: env('SUPABASE_TABLE'),
35+
vectorFieldName: env('SUPABASE_VECTOR_FIELD'),
36+
vectorDimension: (int) env('SUPABASE_VECTOR_DIMENSION'),
37+
functionName: env('SUPABASE_MATCH_FUNCTION'),
3538
);
3639

3740
$documents = [];
@@ -44,20 +47,17 @@
4447
);
4548
}
4649

47-
$platform = PlatformFactory::create(
48-
env('OLLAMA_HOST_URL'),
49-
http_client()
50-
);
50+
$platform = PlatformFactory::create(env('OLLAMA_HOST_URL'), http_client());
5151

52-
$vectorizer = new Vectorizer($platform, new Ollama('mxbai-embed-large'));
52+
$vectorizer = new Vectorizer($platform, env('OLLAMA_EMBEDDINGS'));
5353
$loader = new InMemoryLoader($documents);
5454
$indexer = new Indexer($loader, $vectorizer, $store, logger: logger());
5555
$indexer->index();
5656

5757
$similaritySearch = new SimilaritySearch($vectorizer, $store);
5858
$toolbox = new Toolbox([$similaritySearch], logger: logger());
5959
$processor = new AgentProcessor($toolbox);
60-
$agent = new Agent($platform, new Ollama('llama3.2:3b'), [$processor], [$processor], logger: logger());
60+
$agent = new Agent($platform, env('OLLAMA_LLM'), [$processor], [$processor]);
6161

6262
$messages = new MessageBag(
6363
Message::forSystem('Please answer all user questions only using SimilaritySearch function.'),

src/ai-bundle/config/options.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,12 @@
656656
->defaultValue('http_client')
657657
->info('Service ID of the HTTP client to use')
658658
->end()
659-
->scalarNode('url')->isRequired()->cannotBeEmpty()->end()
660-
->scalarNode('api_key')->isRequired()->cannotBeEmpty()->end()
661-
->scalarNode('table')->end()
662-
->scalarNode('vector_field')->end()
659+
->stringNode('url')->isRequired()->cannotBeEmpty()->end()
660+
->stringNode('api_key')->isRequired()->cannotBeEmpty()->end()
661+
->stringNode('table')->end()
662+
->stringNode('vector_field')->end()
663663
->integerNode('vector_dimension')->end()
664-
->scalarNode('function_name')->end()
664+
->stringNode('function_name')->end()
665665
->end()
666666
->end()
667667
->end()

0 commit comments

Comments
 (0)