Skip to content

Commit e1838aa

Browse files
feat(store): Integrate supabase into the store package
- Adds bundle integration - Adds an entry into the stores factory for supabase
1 parent 25b8f4b commit e1838aa

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
@@ -348,6 +348,19 @@
348348
->end()
349349
->end()
350350
->end()
351+
->arrayNode('supabase')
352+
->useAttributeAsKey('name')
353+
->arrayPrototype()
354+
->children()
355+
->scalarNode('url')->isRequired()->cannotBeEmpty()->end()
356+
->scalarNode('api_key')->isRequired()->cannotBeEmpty()->end()
357+
->scalarNode('table')->isRequired()->cannotBeEmpty()->end()
358+
->scalarNode('vector_field')->end()
359+
->integerNode('vector_dimension')->end()
360+
->scalarNode('function_name')->end()
361+
->end()
362+
->end()
363+
->end()
351364
->arrayNode('typesense')
352365
->useAttributeAsKey('name')
353366
->arrayPrototype()

src/ai-bundle/src/AiBundle.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
use Symfony\AI\Store\Bridge\Neo4j\Store as Neo4jStore;
6363
use Symfony\AI\Store\Bridge\Pinecone\Store as PineconeStore;
6464
use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore;
65+
use Symfony\AI\Store\Bridge\Supabase\Store as SupabaseStore;
6566
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
6667
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
6768
use Symfony\AI\Store\Bridge\Weaviate\Store as WeaviateStore;
@@ -1031,6 +1032,40 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10311032
$container->setDefinition('ai.store.'.$type.'.'.$name, $definition);
10321033
}
10331034
}
1035+
1036+
if ('supabase' === $type) {
1037+
foreach ($stores as $name => $store) {
1038+
$arguments = [
1039+
new Reference('http_client'),
1040+
$store['url'],
1041+
$store['api_key'],
1042+
];
1043+
1044+
if (\array_key_exists('table', $store)) {
1045+
$arguments[3] = $store['table'];
1046+
}
1047+
1048+
if (\array_key_exists('vector_field', $store)) {
1049+
$arguments[4] = $store['vector_field'];
1050+
}
1051+
1052+
if (\array_key_exists('vector_dimension', $store)) {
1053+
$arguments[5] = $store['vector_dimension'];
1054+
}
1055+
1056+
if (\array_key_exists('function_name', $store)) {
1057+
$arguments[6] = $store['function_name'];
1058+
}
1059+
1060+
$definition = new Definition(SupabaseStore::class);
1061+
$definition
1062+
->addTag('ai.store')
1063+
->setArguments($arguments);
1064+
1065+
$container->setDefinition('ai.store.supabase.'.$name, $definition);
1066+
$container->registerAliasForArgument('ai.store.'.$name, StoreInterface::class, (new Target($name.'Store'))->getParsedName());
1067+
}
1068+
}
10341069
}
10351070

10361071
/**

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,16 @@ private function getFullConfig(): array
11961196
'namespaced_user' => true,
11971197
],
11981198
],
1199+
'supabase' => [
1200+
'my_supabase_store' => [
1201+
'url' => 'https://test.supabase.co',
1202+
'api_key' => 'supabase_test_key',
1203+
'table' => 'my_supabase_table',
1204+
'vector_field' => 'my_embedding',
1205+
'vector_dimension' => 1024,
1206+
'function_name' => 'my_match_function',
1207+
],
1208+
],
11991209
'typesense' => [
12001210
'my_typesense_store' => [
12011211
'endpoint' => 'http://localhost:8108',

0 commit comments

Comments
 (0)