3838use Symfony \AI \Store \Bridge \Local \DistanceStrategy ;
3939use Symfony \AI \Store \Bridge \Manticore \Store as ManticoreStore ;
4040use Symfony \AI \Store \Bridge \MariaDb \Store as MariaDbStore ;
41+ use Symfony \AI \Store \Bridge \Milvus \Store as MilvusStore ;
4142use Symfony \AI \Store \Document \Filter \TextContainsFilter ;
4243use Symfony \AI \Store \Document \Loader \InMemoryLoader ;
4344use Symfony \AI \Store \Document \Transformer \TextTrimTransformer ;
4647use Symfony \AI \Store \IndexerInterface ;
4748use Symfony \AI \Store \ManagedStoreInterface ;
4849use Symfony \AI \Store \StoreInterface ;
50+ use Symfony \Component \Clock \ClockInterface ;
4951use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
5052use Symfony \Component \DependencyInjection \ContainerBuilder ;
5153use Symfony \Component \DependencyInjection \ContainerInterface ;
@@ -855,7 +857,10 @@ public function testCloudflareStoreCanBeConfigured()
855857 $ this ->assertSame ('cosine ' , $ definition ->getArgument (5 ));
856858
857859 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
858- $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
860+ $ this ->assertSame ([
861+ ['interface ' => StoreInterface::class],
862+ ['interface ' => ManagedStoreInterface::class],
863+ ], $ definition ->getTag ('proxy ' ));
859864 $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
860865
861866 $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_cloudflare_store ' ));
@@ -900,7 +905,10 @@ public function testCloudflareStoreWithCustomEndpointCanBeConfigured()
900905 $ this ->assertSame ('https://api.cloudflare.com/client/v5/accounts ' , $ definition ->getArgument (6 ));
901906
902907 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
903- $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
908+ $ this ->assertSame ([
909+ ['interface ' => StoreInterface::class],
910+ ['interface ' => ManagedStoreInterface::class],
911+ ], $ definition ->getTag ('proxy ' ));
904912 $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
905913
906914 $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_cloudflare_store ' ));
@@ -945,7 +953,10 @@ public function testManticoreStoreCanBeConfigured()
945953 $ this ->assertSame (768 , $ definition ->getArgument (6 ));
946954
947955 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
948- $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
956+ $ this ->assertSame ([
957+ ['interface ' => StoreInterface::class],
958+ ['interface ' => ManagedStoreInterface::class],
959+ ], $ definition ->getTag ('proxy ' ));
949960 $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
950961
951962 $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_manticore_store ' ));
@@ -992,7 +1003,10 @@ public function testManticoreStoreWithQuantizationCanBeConfigured()
9921003 $ this ->assertSame ('1bit ' , $ definition ->getArgument (7 ));
9931004
9941005 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
995- $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
1006+ $ this ->assertSame ([
1007+ ['interface ' => StoreInterface::class],
1008+ ['interface ' => ManagedStoreInterface::class],
1009+ ], $ definition ->getTag ('proxy ' ));
9961010 $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
9971011
9981012 $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_manticore_store ' ));
@@ -1035,7 +1049,10 @@ public function testMariaDbStoreCanBeConfigured()
10351049 $ this ->assertSame ('vector ' , $ definition ->getArgument (3 ));
10361050
10371051 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
1038- $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
1052+ $ this ->assertSame ([
1053+ ['interface ' => StoreInterface::class],
1054+ ['interface ' => ManagedStoreInterface::class],
1055+ ], $ definition ->getTag ('proxy ' ));
10391056 $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
10401057
10411058 $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_mariadb_store ' ));
@@ -1078,7 +1095,10 @@ public function testMeilisearchStoreCanBeConfigured()
10781095 $ this ->assertSame (1.0 , $ definition ->getArgument (7 ));
10791096
10801097 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
1081- $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
1098+ $ this ->assertSame ([
1099+ ['interface ' => StoreInterface::class],
1100+ ['interface ' => ManagedStoreInterface::class],
1101+ ], $ definition ->getTag ('proxy ' ));
10821102 $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
10831103
10841104 $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $custom ' ));
@@ -1123,7 +1143,10 @@ public function testMeilisearchStoreWithCustomSemanticRatioCanBeConfigured()
11231143 $ this ->assertSame (0.5 , $ definition ->getArgument (7 ));
11241144
11251145 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
1126- $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
1146+ $ this ->assertSame ([
1147+ ['interface ' => StoreInterface::class],
1148+ ['interface ' => ManagedStoreInterface::class],
1149+ ], $ definition ->getTag ('proxy ' ));
11271150 $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
11281151
11291152 $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $custom ' ));
@@ -1150,6 +1173,19 @@ public function testInMemoryStoreWithoutCustomStrategyCanBeConfigured()
11501173 $ this ->assertCount (1 , $ definition ->getArguments ());
11511174 $ this ->assertInstanceOf (Definition::class, $ definition ->getArgument (0 ));
11521175 $ this ->assertSame (DistanceCalculator::class, $ definition ->getArgument (0 )->getClass ());
1176+
1177+ $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
1178+ $ this ->assertSame ([
1179+ ['interface ' => StoreInterface::class],
1180+ ['interface ' => ManagedStoreInterface::class],
1181+ ], $ definition ->getTag ('proxy ' ));
1182+ $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
1183+
1184+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_memory_store_with_custom_strategy ' ));
1185+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $myMemoryStoreWithCustomStrategy ' ));
1186+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $memory_my_memory_store_with_custom_strategy ' ));
1187+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $memoryMyMemoryStoreWithCustomStrategy ' ));
1188+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface ' ));
11531189 }
11541190
11551191 public function testInMemoryStoreWithCustomStrategyCanBeConfigured ()
@@ -1174,6 +1210,119 @@ public function testInMemoryStoreWithCustomStrategyCanBeConfigured()
11741210 $ this ->assertCount (1 , $ definition ->getArguments ());
11751211 $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
11761212 $ this ->assertSame ('ai.store.distance_calculator.my_memory_store_with_custom_strategy ' , (string ) $ definition ->getArgument (0 ));
1213+
1214+ $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
1215+ $ this ->assertSame ([
1216+ ['interface ' => StoreInterface::class],
1217+ ['interface ' => ManagedStoreInterface::class],
1218+ ], $ definition ->getTag ('proxy ' ));
1219+ $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
1220+
1221+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_memory_store_with_custom_strategy ' ));
1222+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $myMemoryStoreWithCustomStrategy ' ));
1223+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $memory_my_memory_store_with_custom_strategy ' ));
1224+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $memoryMyMemoryStoreWithCustomStrategy ' ));
1225+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface ' ));
1226+ }
1227+
1228+ public function testMilvusStoreCanBeConfigured ()
1229+ {
1230+ $ container = $ this ->buildContainer ([
1231+ 'ai ' => [
1232+ 'store ' => [
1233+ 'milvus ' => [
1234+ 'my_milvus_store ' => [
1235+ 'endpoint ' => 'http://127.0.0.1:19530 ' ,
1236+ 'api_key ' => 'foo ' ,
1237+ 'database ' => 'test ' ,
1238+ 'collection ' => 'default ' ,
1239+ 'vector_field ' => '_vectors ' ,
1240+ 'dimensions ' => 768 ,
1241+ ],
1242+ ],
1243+ ],
1244+ ],
1245+ ]);
1246+
1247+ $ this ->assertTrue ($ container ->hasDefinition ('ai.store.milvus.my_milvus_store ' ));
1248+
1249+ $ definition = $ container ->getDefinition ('ai.store.milvus.my_milvus_store ' );
1250+ $ this ->assertSame (MilvusStore::class, $ definition ->getClass ());
1251+
1252+ $ this ->assertTrue ($ definition ->isLazy ());
1253+ $ this ->assertCount (7 , $ definition ->getArguments ());
1254+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
1255+ $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (0 ));
1256+ $ this ->assertSame ('http://127.0.0.1:19530 ' , $ definition ->getArgument (1 ));
1257+ $ this ->assertSame ('foo ' , $ definition ->getArgument (2 ));
1258+ $ this ->assertSame ('test ' , $ definition ->getArgument (3 ));
1259+ $ this ->assertSame ('default ' , $ definition ->getArgument (4 ));
1260+ $ this ->assertSame ('_vectors ' , $ definition ->getArgument (5 ));
1261+ $ this ->assertSame (768 , $ definition ->getArgument (6 ));
1262+
1263+ $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
1264+ $ this ->assertSame ([
1265+ ['interface ' => StoreInterface::class],
1266+ ['interface ' => ManagedStoreInterface::class],
1267+ ], $ definition ->getTag ('proxy ' ));
1268+ $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
1269+
1270+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_milvus_store ' ));
1271+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $myMilvusStore ' ));
1272+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $milvus_my_milvus_store ' ));
1273+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $milvusMyMilvusStore ' ));
1274+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface ' ));
1275+ }
1276+
1277+ public function testMilvusStoreWithCustomMetricsCanBeConfigured ()
1278+ {
1279+ $ container = $ this ->buildContainer ([
1280+ 'ai ' => [
1281+ 'store ' => [
1282+ 'milvus ' => [
1283+ 'my_milvus_store ' => [
1284+ 'endpoint ' => 'http://127.0.0.1:19530 ' ,
1285+ 'api_key ' => 'foo ' ,
1286+ 'database ' => 'test ' ,
1287+ 'collection ' => 'default ' ,
1288+ 'vector_field ' => '_vectors ' ,
1289+ 'dimensions ' => 768 ,
1290+ 'metric_type ' => 'COSINE ' ,
1291+ ],
1292+ ],
1293+ ],
1294+ ],
1295+ ]);
1296+
1297+ $ this ->assertTrue ($ container ->hasDefinition ('ai.store.milvus.my_milvus_store ' ));
1298+
1299+ $ definition = $ container ->getDefinition ('ai.store.milvus.my_milvus_store ' );
1300+ $ this ->assertSame (MilvusStore::class, $ definition ->getClass ());
1301+
1302+ $ this ->assertTrue ($ definition ->isLazy ());
1303+ $ this ->assertCount (8 , $ definition ->getArguments ());
1304+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
1305+ $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (0 ));
1306+ $ this ->assertSame ('http://127.0.0.1:19530 ' , $ definition ->getArgument (1 ));
1307+ $ this ->assertSame ('foo ' , $ definition ->getArgument (2 ));
1308+ $ this ->assertSame ('test ' , $ definition ->getArgument (3 ));
1309+ $ this ->assertSame ('default ' , $ definition ->getArgument (4 ));
1310+ $ this ->assertSame ('_vectors ' , $ definition ->getArgument (5 ));
1311+ $ this ->assertSame (768 , $ definition ->getArgument (6 ));
1312+ $ this ->assertSame ('COSINE ' , $ definition ->getArgument (7 ));
1313+
1314+ $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
1315+ $ this ->assertSame ([
1316+ ['interface ' => StoreInterface::class],
1317+ ['interface ' => ManagedStoreInterface::class],
1318+ ], $ definition ->getTag ('proxy ' ));
1319+ $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
1320+
1321+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $my_milvus_store ' ));
1322+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $myMilvusStore ' ));
1323+ $ this ->assertTrue ($ container ->hasAlias ('.Symfony\AI\Store\StoreInterface $milvus_my_milvus_store ' ));
1324+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface $milvusMyMilvusStore ' ));
1325+ $ this ->assertTrue ($ container ->hasAlias ('Symfony\AI\Store\StoreInterface ' ));
11771326 }
11781327
11791328 public function testPostgresStoreWithDifferentConnectionCanBeConfigured ()
@@ -3788,30 +3937,6 @@ public function testMeilisearchMessageStoreIsConfigured()
37883937 $ this ->assertTrue ($ definition ->hasTag ('ai.message_store ' ));
37893938 }
37903939
3791- #[TestDox('Meilisearch store with custom semantic_ratio can be configured ' )]
3792- public function testMeilisearchStoreWithCustomSemanticRatioCanBeConfigured ()
3793- {
3794- $ container = $ this ->buildContainer ([
3795- 'ai ' => [
3796- 'store ' => [
3797- 'meilisearch ' => [
3798- 'test_store ' => [
3799- 'endpoint ' => 'http://127.0.0.1:7700 ' ,
3800- 'api_key ' => 'test_key ' ,
3801- 'index_name ' => 'test_index ' ,
3802- 'semantic_ratio ' => 0.5 ,
3803- ],
3804- ],
3805- ],
3806- ],
3807- ]);
3808-
3809- $ this ->assertTrue ($ container ->hasDefinition ('ai.store.meilisearch.test_store ' ));
3810- $ definition = $ container ->getDefinition ('ai.store.meilisearch.test_store ' );
3811- $ arguments = $ definition ->getArguments ();
3812- $ this ->assertSame (0.5 , $ arguments [7 ]);
3813- }
3814-
38153940 public function testMemoryMessageStoreCanBeConfiguredWithCustomKey ()
38163941 {
38173942 $ container = $ this ->buildContainer ([
@@ -4518,6 +4643,14 @@ private function getFullConfig(): array
45184643 'collection ' => 'default ' ,
45194644 'vector_field ' => '_vectors ' ,
45204645 'dimensions ' => 768 ,
4646+ ],
4647+ 'my_milvus_store_with_custom_metric_type ' => [
4648+ 'endpoint ' => 'http://127.0.0.1:19530 ' ,
4649+ 'api_key ' => 'foo ' ,
4650+ 'database ' => 'test ' ,
4651+ 'collection ' => 'default ' ,
4652+ 'vector_field ' => '_vectors ' ,
4653+ 'dimensions ' => 768 ,
45214654 'metric_type ' => 'COSINE ' ,
45224655 ],
45234656 ],
0 commit comments