Skip to content

Commit 0d37568

Browse files
junaidbinfarooqchr-hertel
authored andcommitted
docs(store): Integrate supabase into the store package
- Adds documentation for the new store integration
1 parent b4b5067 commit 0d37568

File tree

11 files changed

+292
-101
lines changed

11 files changed

+292
-101
lines changed

docs/components/store.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ You can find more advanced usage in combination with an Agent using the store fo
4848
* `Similarity Search with Symfony Cache (RAG)`_
4949
* `Similarity Search with Typesense (RAG)`_
5050
* `Similarity Search with Weaviate (RAG)`_
51+
* `Similarity Search with Supabase (RAG)`_
5152

5253
.. note::
5354

@@ -70,6 +71,7 @@ Supported Stores
7071
* `Pinecone`_ (requires `probots-io/pinecone-php` as additional dependency)
7172
* `Postgres`_ (requires `ext-pdo`)
7273
* `Qdrant`_
74+
* `Supabase`_ (requires manual database setup)
7375
* `SurrealDB`_
7476
* `Symfony Cache`_ (requires `symfony/cache` as additional dependency)
7577
* `Typesense`_
@@ -137,6 +139,7 @@ This leads to a store implementing two methods::
137139
.. _`Similarity Search with Qdrant (RAG)`: https://github.com/symfony/ai/blob/main/examples/rag/qdrant.php
138140
.. _`Similarity Search with SurrealDB (RAG)`: https://github.com/symfony/ai/blob/main/examples/rag/surrealdb.php
139141
.. _`Similarity Search with Typesense (RAG)`: https://github.com/symfony/ai/blob/main/examples/rag/typesense.php
142+
.. _`Similarity Search with Supabase (RAG)`: https://github.com/symfony/ai/blob/main/examples/rag/supabase.php
140143
.. _`Similarity Search with Weaviate (RAG)`: https://github.com/symfony/ai/blob/main/examples/rag/weaviate.php
141144
.. _`Azure AI Search`: https://azure.microsoft.com/products/ai-services/ai-search
142145
.. _`Chroma`: https://www.trychroma.com/
@@ -154,3 +157,4 @@ This leads to a store implementing two methods::
154157
.. _`Typesense`: https://typesense.org/
155158
.. _`Symfony Cache`: https://symfony.com/doc/current/components/cache.html
156159
.. _`Weaviate`: https://weaviate.io/
160+
.. _`Supabase`: https://https://supabase.com/

examples/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ SCALEWAY_SECRET_KEY=
157157
# For using DeepSeek
158158
DEEPSEEK_API_KEY=
159159

160-
# Supabase
160+
# Supabase (store)
161161
SUPABASE_URL=
162162
SUPABASE_API_KEY=
163163
SUPABASE_TABLE=

examples/commands/stores.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Symfony\AI\Store\Bridge\Neo4j\Store as Neo4jStore;
2525
use Symfony\AI\Store\Bridge\Postgres\Store as PostgresStore;
2626
use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore;
27-
use Symfony\AI\Store\Bridge\Supabase\Store as SupabaseStore;
2827
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
2928
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
3029
use Symfony\AI\Store\Bridge\Weaviate\Store as WeaviateStore;
@@ -89,15 +88,6 @@
8988
env('QDRANT_SERVICE_API_KEY'),
9089
'symfony',
9190
),
92-
'supabase' => static fn (): SupabaseStore => new SupabaseStore(
93-
http_client(),
94-
env('SUPABASE_URL'),
95-
env('SUPABASE_API_KEY'),
96-
env('SUPABASE_TABLE'),
97-
env('SUPABASE_VECTOR_FIELD'),
98-
env('SUPABASE_VECTOR_DIMENSION'),
99-
env('SUPABASE_MATCH_FUNCTION'),
100-
),
10191
'surrealdb' => static fn (): SurrealDbStore => new SurrealDbStore(
10292
httpClient: http_client(),
10393
endpointUrl: env('SURREALDB_HOST'),

examples/rag/supabase.php

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,10 @@
2828

2929
require_once dirname(__DIR__).'/bootstrap.php';
3030

31-
echo "Make sure you've run the SQL setup from SUPABASE_SETUP.md first!\n\n";
32-
3331
$store = new Store(
34-
http: http_client(),
32+
httpClient: http_client(),
3533
url: env('SUPABASE_URL'),
3634
apiKey: env('SUPABASE_API_KEY'),
37-
table: env('SUPABASE_TABLE'),
38-
vectorFieldName: env('SUPABASE_VECTOR_FIELD'),
39-
vectorDimension: (int) env('SUPABASE_VECTOR_DIMENSION'),
40-
functionName: env('SUPABASE_MATCH_FUNCTION')
4135
);
4236

4337
$documents = [];
@@ -51,49 +45,25 @@ functionName: env('SUPABASE_MATCH_FUNCTION')
5145
}
5246

5347
$platform = PlatformFactory::create(
54-
env('OLLAMA_HOST_URL') ?? 'http://localhost:11434',
48+
env('OLLAMA_HOST_URL'),
5549
http_client()
5650
);
5751

58-
$embeddingModel = new Ollama('mxbai-embed-large');
59-
$vectorizer = new Vectorizer($platform, $embeddingModel);
52+
$vectorizer = new Vectorizer($platform, new Ollama('mxbai-embed-large'));
6053
$loader = new InMemoryLoader($documents);
6154
$indexer = new Indexer($loader, $vectorizer, $store, logger: logger());
6255
$indexer->index();
6356

64-
$chatModel = new Ollama('llama3.2:3b');
65-
6657
$similaritySearch = new SimilaritySearch($vectorizer, $store);
6758
$toolbox = new Toolbox([$similaritySearch], logger: logger());
6859
$processor = new AgentProcessor($toolbox);
69-
$agent = new Agent($platform, $chatModel, [$processor], [$processor], logger: logger());
60+
$agent = new Agent($platform, new Ollama('llama3.2:3b'), [$processor], [$processor], logger: logger());
7061

7162
$messages = new MessageBag(
7263
Message::forSystem('Please answer all user questions only using SimilaritySearch function.'),
7364
Message::ofUser('Which movie fits the theme of technology?')
7465
);
7566

76-
echo "Query: Which movie fits the theme of technology?\n";
77-
echo "Processing...\n";
67+
$result = $agent->call($messages);
7868

79-
try {
80-
$result = $agent->call($messages);
81-
echo '✅ Response: '.$result->getContent()."\n\n";
82-
} catch (Exception $e) {
83-
echo '❌ Error: '.$e->getMessage()."\n\n";
84-
}
85-
86-
$messages2 = new MessageBag(
87-
Message::forSystem('Please answer all user questions only using SimilaritySearch function.'),
88-
Message::ofUser('What are some good action movies?')
89-
);
90-
91-
echo "Query: What are some good action movies?\n";
92-
echo "Processing...\n";
93-
94-
try {
95-
$result2 = $agent->call($messages2);
96-
echo '✅ Response: '.$result2->getContent()."\n\n";
97-
} catch (Exception $e) {
98-
echo '❌ Error: '.$e->getMessage()."\n\n";
99-
}
69+
echo $result->getContent().\PHP_EOL;

src/ai-bundle/config/options.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,14 @@
651651
->useAttributeAsKey('name')
652652
->arrayPrototype()
653653
->children()
654+
->stringNode('http_client')
655+
->cannotBeEmpty()
656+
->defaultValue('http_client')
657+
->info('Service ID of the HTTP client to use')
658+
->end()
654659
->scalarNode('url')->isRequired()->cannotBeEmpty()->end()
655660
->scalarNode('api_key')->isRequired()->cannotBeEmpty()->end()
656-
->scalarNode('table')->isRequired()->cannotBeEmpty()->end()
661+
->scalarNode('table')->end()
657662
->scalarNode('vector_field')->end()
658663
->integerNode('vector_dimension')->end()
659664
->scalarNode('function_name')->end()

src/ai-bundle/src/AiBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ private function processMessageStoreConfig(string $type, array $messageStores, C
13231323
if ('supabase' === $type) {
13241324
foreach ($stores as $name => $store) {
13251325
$arguments = [
1326-
new Reference('http_client'),
1326+
isset($store['http_client']) ? new Reference($store['http_client']) : new Definition(HttpClientInterface::class),
13271327
$store['url'],
13281328
$store['api_key'],
13291329
];

src/store/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ CHANGELOG
4646
- PostgreSQL with pgvector extension
4747
- Qdrant
4848
- Redis
49+
- Supabase
4950
- SurrealDB
5051
- Typesense
5152
- Weaviate

src/store/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"pinecone",
1818
"postgres",
1919
"qdrant",
20+
"supabase",
2021
"surrealdb",
2122
"typesense",
2223
"weaviate"

0 commit comments

Comments
 (0)