Skip to content

Commit 6a9c393

Browse files
feat(store): Integrate supabase into the store package
- Adds bundle integration - Adds an entry into the stores factory for supabase
1 parent 67085ed commit 6a9c393

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

examples/commands/stores.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
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;
2728
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
2829
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
2930
use Symfony\AI\Store\Bridge\Weaviate\Store as WeaviateStore;
@@ -88,6 +89,15 @@
8889
env('QDRANT_SERVICE_API_KEY'),
8990
'symfony',
9091
),
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+
),
91101
'surrealdb' => static fn (): SurrealDbStore => new SurrealDbStore(
92102
httpClient: http_client(),
93103
endpointUrl: env('SURREALDB_HOST'),

src/ai-bundle/config/options.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,19 @@
375375
->end()
376376
->end()
377377
->end()
378+
->arrayNode('supabase')
379+
->useAttributeAsKey('name')
380+
->arrayPrototype()
381+
->children()
382+
->scalarNode('url')->isRequired()->cannotBeEmpty()->end()
383+
->scalarNode('api_key')->isRequired()->cannotBeEmpty()->end()
384+
->scalarNode('table')->isRequired()->cannotBeEmpty()->end()
385+
->scalarNode('vector_field')->end()
386+
->integerNode('vector_dimension')->end()
387+
->scalarNode('function_name')->end()
388+
->end()
389+
->end()
390+
->end()
378391
->arrayNode('typesense')
379392
->useAttributeAsKey('name')
380393
->arrayPrototype()

src/ai-bundle/src/AiBundle.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
use Symfony\AI\Store\Bridge\Neo4j\Store as Neo4jStore;
6464
use Symfony\AI\Store\Bridge\Pinecone\Store as PineconeStore;
6565
use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore;
66+
use Symfony\AI\Store\Bridge\Supabase\Store as SupabaseStore;
6667
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
6768
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
6869
use Symfony\AI\Store\Bridge\Weaviate\Store as WeaviateStore;
@@ -1052,6 +1053,40 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10521053
$container->setDefinition('ai.store.'.$type.'.'.$name, $definition);
10531054
}
10541055
}
1056+
1057+
if ('supabase' === $type) {
1058+
foreach ($stores as $name => $store) {
1059+
$arguments = [
1060+
new Reference('http_client'),
1061+
$store['url'],
1062+
$store['api_key'],
1063+
];
1064+
1065+
if (\array_key_exists('table', $store)) {
1066+
$arguments[3] = $store['table'];
1067+
}
1068+
1069+
if (\array_key_exists('vector_field', $store)) {
1070+
$arguments[4] = $store['vector_field'];
1071+
}
1072+
1073+
if (\array_key_exists('vector_dimension', $store)) {
1074+
$arguments[5] = $store['vector_dimension'];
1075+
}
1076+
1077+
if (\array_key_exists('function_name', $store)) {
1078+
$arguments[6] = $store['function_name'];
1079+
}
1080+
1081+
$definition = new Definition(SupabaseStore::class);
1082+
$definition
1083+
->addTag('ai.store')
1084+
->setArguments($arguments);
1085+
1086+
$container->setDefinition('ai.store.supabase.'.$name, $definition);
1087+
$container->registerAliasForArgument('ai.store.'.$name, StoreInterface::class, (new Target($name.'Store'))->getParsedName());
1088+
}
1089+
}
10551090
}
10561091

10571092
/**

src/ai-bundle/tests/DependencyInjection/AiBundleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,16 @@ private function getFullConfig(): array
14171417
'namespaced_user' => true,
14181418
],
14191419
],
1420+
'supabase' => [
1421+
'my_supabase_store' => [
1422+
'url' => 'https://test.supabase.co',
1423+
'api_key' => 'supabase_test_key',
1424+
'table' => 'my_supabase_table',
1425+
'vector_field' => 'my_embedding',
1426+
'vector_dimension' => 1024,
1427+
'function_name' => 'my_match_function',
1428+
],
1429+
],
14201430
'typesense' => [
14211431
'my_typesense_store' => [
14221432
'endpoint' => 'http://localhost:8108',

0 commit comments

Comments
 (0)