diff --git a/src/ai-bundle/config/options.php b/src/ai-bundle/config/options.php index 647d34c21..ee536d253 100644 --- a/src/ai-bundle/config/options.php +++ b/src/ai-bundle/config/options.php @@ -581,6 +581,17 @@ ->end() ->end() ->end() + ->arrayNode('mariadb') + ->useAttributeAsKey('name') + ->arrayPrototype() + ->children() + ->stringNode('connection')->cannotBeEmpty()->end() + ->stringNode('table_name')->cannotBeEmpty()->end() + ->stringNode('index_name')->cannotBeEmpty()->end() + ->stringNode('vector_field_name')->cannotBeEmpty()->end() + ->end() + ->end() + ->end() ->arrayNode('milvus') ->useAttributeAsKey('name') ->arrayPrototype() diff --git a/src/ai-bundle/src/AiBundle.php b/src/ai-bundle/src/AiBundle.php index f605fc7ce..52f8241d6 100644 --- a/src/ai-bundle/src/AiBundle.php +++ b/src/ai-bundle/src/AiBundle.php @@ -78,6 +78,7 @@ use Symfony\AI\Store\Bridge\Local\DistanceStrategy; use Symfony\AI\Store\Bridge\Local\InMemoryStore; use Symfony\AI\Store\Bridge\Manticore\Store as ManticoreStore; +use Symfony\AI\Store\Bridge\MariaDb\Store as MariaDbStore; use Symfony\AI\Store\Bridge\Meilisearch\Store as MeilisearchStore; use Symfony\AI\Store\Bridge\Milvus\Store as MilvusStore; use Symfony\AI\Store\Bridge\MongoDb\Store as MongoDbStore; @@ -1060,6 +1061,28 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde } } + if ('mariadb' === $type) { + foreach ($stores as $name => $store) { + $arguments = [ + new Reference(\sprintf('doctrine.dbal.%s_connection', $store['connection'])), + $store['table_name'], + $store['index_name'], + $store['vector_field_name'], + ]; + + $definition = new Definition(MariaDbStore::class); + $definition->setFactory([MariaDbStore::class, 'fromDbal']); + $definition + ->addTag('ai.store') + ->setArguments($arguments); + + $serviceId = 'ai.store.'.$type.'.'.$name; + $container->setDefinition($serviceId, $definition); + $container->registerAliasForArgument($serviceId, StoreInterface::class, $name); + $container->registerAliasForArgument($serviceId, StoreInterface::class, $type.'_'.$name); + } + } + if ('meilisearch' === $type) { foreach ($stores as $name => $store) { $arguments = [ diff --git a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php index 9558a4b02..515e3f457 100644 --- a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php +++ b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php @@ -3254,6 +3254,14 @@ private function getFullConfig(): array 'quantization' => '1bit', ], ], + 'mariadb' => [ + 'my_mariadb_store' => [ + 'connection' => 'default', + 'table_name' => 'vector_table', + 'index_name' => 'vector_idx', + 'vector_field_name' => 'vector', + ], + ], 'meilisearch' => [ 'my_meilisearch_store' => [ 'endpoint' => 'http://127.0.0.1:7700',