Skip to content

Commit 4d3e544

Browse files
committed
feature #904 [Store][AiBundle] Add support for MariaDB (lyrixx)
This PR was merged into the main branch. Discussion ---------- [Store][AiBundle] Add support for MariaDB | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | | License | MIT Commits ------- 06b63b0 [AiBundle][Store] Add support for MariaDB
2 parents a77d71d + 06b63b0 commit 4d3e544

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/ai-bundle/config/options.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,17 @@
587587
->end()
588588
->end()
589589
->end()
590+
->arrayNode('mariadb')
591+
->useAttributeAsKey('name')
592+
->arrayPrototype()
593+
->children()
594+
->stringNode('connection')->cannotBeEmpty()->end()
595+
->stringNode('table_name')->cannotBeEmpty()->end()
596+
->stringNode('index_name')->cannotBeEmpty()->end()
597+
->stringNode('vector_field_name')->cannotBeEmpty()->end()
598+
->end()
599+
->end()
600+
->end()
590601
->arrayNode('milvus')
591602
->useAttributeAsKey('name')
592603
->arrayPrototype()

src/ai-bundle/src/AiBundle.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
use Symfony\AI\Store\Bridge\Local\DistanceStrategy;
7979
use Symfony\AI\Store\Bridge\Local\InMemoryStore;
8080
use Symfony\AI\Store\Bridge\Manticore\Store as ManticoreStore;
81+
use Symfony\AI\Store\Bridge\MariaDb\Store as MariaDbStore;
8182
use Symfony\AI\Store\Bridge\Meilisearch\Store as MeilisearchStore;
8283
use Symfony\AI\Store\Bridge\Milvus\Store as MilvusStore;
8384
use Symfony\AI\Store\Bridge\MongoDb\Store as MongoDbStore;
@@ -1060,6 +1061,28 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10601061
}
10611062
}
10621063

1064+
if ('mariadb' === $type) {
1065+
foreach ($stores as $name => $store) {
1066+
$arguments = [
1067+
new Reference(\sprintf('doctrine.dbal.%s_connection', $store['connection'])),
1068+
$store['table_name'],
1069+
$store['index_name'],
1070+
$store['vector_field_name'],
1071+
];
1072+
1073+
$definition = new Definition(MariaDbStore::class);
1074+
$definition->setFactory([MariaDbStore::class, 'fromDbal']);
1075+
$definition
1076+
->addTag('ai.store')
1077+
->setArguments($arguments);
1078+
1079+
$serviceId = 'ai.store.'.$type.'.'.$name;
1080+
$container->setDefinition($serviceId, $definition);
1081+
$container->registerAliasForArgument($serviceId, StoreInterface::class, $name);
1082+
$container->registerAliasForArgument($serviceId, StoreInterface::class, $type.'_'.$name);
1083+
}
1084+
}
1085+
10631086
if ('meilisearch' === $type) {
10641087
foreach ($stores as $name => $store) {
10651088
$arguments = [

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3278,6 +3278,14 @@ private function getFullConfig(): array
32783278
'quantization' => '1bit',
32793279
],
32803280
],
3281+
'mariadb' => [
3282+
'my_mariadb_store' => [
3283+
'connection' => 'default',
3284+
'table_name' => 'vector_table',
3285+
'index_name' => 'vector_idx',
3286+
'vector_field_name' => 'vector',
3287+
],
3288+
],
32813289
'meilisearch' => [
32823290
'my_meilisearch_store' => [
32833291
'endpoint' => 'http://127.0.0.1:7700',

0 commit comments

Comments
 (0)