@@ -929,7 +929,7 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
929929 * @param array<string, mixed> $stores
930930 * @param array<string, mixed> $setupStoresOptions
931931 */
932- private function processStoreConfig (string $ type , array $ stores , ContainerBuilder $ container , &$ setupStoresOptions ): void
932+ private function processStoreConfig (string $ type , array $ stores , ContainerBuilder $ container , array &$ setupStoresOptions ): void
933933 {
934934 if ('azure_search ' === $ type ) {
935935 foreach ($ stores as $ name => $ store ) {
@@ -947,8 +947,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
947947
948948 $ definition = new Definition (AzureSearchStore::class);
949949 $ definition
950- ->addTag ('ai.store ' )
951- ->setArguments ($ arguments );
950+ ->setLazy (true )
951+ ->setArguments ($ arguments )
952+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
953+ ->addTag ('ai.store ' );
952954
953955 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
954956 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -961,6 +963,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
961963 $ arguments = [
962964 new Reference ($ store ['service ' ]),
963965 new Definition (DistanceCalculator::class),
966+ $ store ['cache_key ' ] ?? $ name ,
964967 ];
965968
966969 if (\array_key_exists ('strategy ' , $ store ) && null !== $ store ['strategy ' ]) {
@@ -974,13 +977,11 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
974977 $ arguments [1 ] = new Reference ('ai.store.distance_calculator. ' .$ name );
975978 }
976979
977- $ arguments [2 ] = \array_key_exists ('cache_key ' , $ store ) && null !== $ store ['cache_key ' ]
978- ? $ store ['cache_key ' ]
979- : $ name ;
980-
981980 $ definition = new Definition (CacheStore::class);
982981 $ definition
982+ ->setLazy (true )
983983 ->setArguments ($ arguments )
984+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
984985 ->addTag ('ai.store ' );
985986
986987 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
@@ -993,10 +994,12 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
993994 foreach ($ stores as $ name => $ store ) {
994995 $ definition = new Definition (ChromaDbStore::class);
995996 $ definition
997+ ->setLazy (true )
996998 ->setArguments ([
997999 new Reference ($ store ['client ' ]),
9981000 $ store ['collection ' ],
9991001 ])
1002+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
10001003 ->addTag ('ai.store ' );
10011004
10021005 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
@@ -1019,11 +1022,13 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10191022
10201023 $ definition = new Definition (ClickHouseStore::class);
10211024 $ definition
1025+ ->setLazy (true )
10221026 ->setArguments ([
10231027 $ httpClient ,
10241028 $ store ['database ' ],
10251029 $ store ['table ' ],
10261030 ])
1031+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
10271032 ->addTag ('ai.store ' )
10281033 ;
10291034
@@ -1056,8 +1061,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10561061
10571062 $ definition = new Definition (CloudflareStore::class);
10581063 $ definition
1059- ->addTag ('ai.store ' )
1060- ->setArguments ($ arguments );
1064+ ->setLazy (true )
1065+ ->setArguments ($ arguments )
1066+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1067+ ->addTag ('ai.store ' );
10611068
10621069 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
10631070 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1095,7 +1102,9 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10951102
10961103 $ definition = new Definition (ManticoreStore::class);
10971104 $ definition
1105+ ->setLazy (true )
10981106 ->addTag ('ai.store ' )
1107+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
10991108 ->setArguments ($ arguments );
11001109
11011110 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
@@ -1116,8 +1125,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11161125 $ definition = new Definition (MariaDbStore::class);
11171126 $ definition ->setFactory ([MariaDbStore::class, 'fromDbal ' ]);
11181127 $ definition
1119- ->addTag ('ai.store ' )
1120- ->setArguments ($ arguments );
1128+ ->setLazy (true )
1129+ ->setArguments ($ arguments )
1130+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1131+ ->addTag ('ai.store ' );
11211132
11221133 $ serviceId = 'ai.store. ' .$ type .'. ' .$ name ;
11231134 $ container ->setDefinition ($ serviceId , $ definition );
@@ -1155,8 +1166,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11551166
11561167 $ definition = new Definition (MeilisearchStore::class);
11571168 $ definition
1158- ->addTag ('ai.store ' )
1159- ->setArguments ($ arguments );
1169+ ->setLazy (true )
1170+ ->setArguments ($ arguments )
1171+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1172+ ->addTag ('ai.store ' );
11601173
11611174 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
11621175 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1166,7 +1179,9 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11661179
11671180 if ('memory ' === $ type ) {
11681181 foreach ($ stores as $ name => $ store ) {
1169- $ arguments = [];
1182+ $ arguments = [
1183+ new Definition (DistanceCalculator::class),
1184+ ];
11701185
11711186 if (\array_key_exists ('strategy ' , $ store ) && null !== $ store ['strategy ' ]) {
11721187 if (!$ container ->hasDefinition ('ai.store.distance_calculator. ' .$ name )) {
@@ -1181,8 +1196,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11811196
11821197 $ definition = new Definition (InMemoryStore::class);
11831198 $ definition
1184- ->addTag ('ai.store ' )
1185- ->setArguments ($ arguments );
1199+ ->setLazy (true )
1200+ ->setArguments ($ arguments )
1201+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1202+ ->addTag ('ai.store ' );
11861203
11871204 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
11881205 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1214,8 +1231,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
12141231
12151232 $ definition = new Definition (MilvusStore::class);
12161233 $ definition
1217- ->addTag ('ai.store ' )
1218- ->setArguments ($ arguments );
1234+ ->setLazy (true )
1235+ ->setArguments ($ arguments )
1236+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1237+ ->addTag ('ai.store ' );
12191238
12201239 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
12211240 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1242,8 +1261,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
12421261
12431262 $ definition = new Definition (MongoDbStore::class);
12441263 $ definition
1245- ->addTag ('ai.store ' )
1246- ->setArguments ($ arguments );
1264+ ->setLazy (true )
1265+ ->setArguments ($ arguments )
1266+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1267+ ->addTag ('ai.store ' );
12471268
12481269 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
12491270 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1281,8 +1302,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
12811302
12821303 $ definition = new Definition (Neo4jStore::class);
12831304 $ definition
1284- ->addTag ('ai.store ' )
1285- ->setArguments ($ arguments );
1305+ ->setLazy (true )
1306+ ->setArguments ($ arguments )
1307+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1308+ ->addTag ('ai.store ' );
12861309
12871310 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
12881311 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1307,8 +1330,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
13071330
13081331 $ definition = new Definition (PineconeStore::class);
13091332 $ definition
1310- ->addTag ('ai.store ' )
1311- ->setArguments ($ arguments );
1333+ ->setLazy (true )
1334+ ->setArguments ($ arguments )
1335+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1336+ ->addTag ('ai.store ' );
13121337
13131338 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
13141339 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1339,8 +1364,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
13391364
13401365 $ definition = new Definition (QdrantStore::class);
13411366 $ definition
1342- ->addTag ('ai.store ' )
1343- ->setArguments ($ arguments );
1367+ ->setLazy (true )
1368+ ->setArguments ($ arguments )
1369+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1370+ ->addTag ('ai.store ' );
13441371
13451372 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
13461373 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1359,14 +1386,15 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
13591386
13601387 $ definition = new Definition (RedisStore::class);
13611388 $ definition
1362- ->addTag ( ' ai.store ' )
1389+ ->setLazy ( true )
13631390 ->setArguments ([
13641391 $ redisClient ,
13651392 $ store ['index_name ' ],
13661393 $ store ['key_prefix ' ],
13671394 $ store ['distance ' ],
13681395 ])
1369- ;
1396+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1397+ ->addTag ('ai.store ' );
13701398
13711399 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
13721400 }
@@ -1405,8 +1433,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
14051433
14061434 $ definition = new Definition (SurrealDbStore::class);
14071435 $ definition
1408- ->addTag ('ai.store ' )
1409- ->setArguments ($ arguments );
1436+ ->setLazy (true )
1437+ ->setArguments ($ arguments )
1438+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1439+ ->addTag ('ai.store ' );
14101440
14111441 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
14121442 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1433,8 +1463,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
14331463
14341464 $ definition = new Definition (TypesenseStore::class);
14351465 $ definition
1436- ->addTag ('ai.store ' )
1437- ->setArguments ($ arguments );
1466+ ->setLazy (true )
1467+ ->setArguments ($ arguments )
1468+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1469+ ->addTag ('ai.store ' );
14381470
14391471 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
14401472 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1444,17 +1476,17 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
14441476
14451477 if ('weaviate ' === $ type ) {
14461478 foreach ($ stores as $ name => $ store ) {
1447- $ arguments = [
1448- new Reference ('http_client ' ),
1449- $ store ['endpoint ' ],
1450- $ store ['api_key ' ],
1451- $ store ['collection ' ],
1452- ];
1453-
14541479 $ definition = new Definition (WeaviateStore::class);
14551480 $ definition
1456- ->addTag ('ai.store ' )
1457- ->setArguments ($ arguments );
1481+ ->setLazy (true )
1482+ ->setArguments ([
1483+ new Reference ('http_client ' ),
1484+ $ store ['endpoint ' ],
1485+ $ store ['api_key ' ],
1486+ $ store ['collection ' ],
1487+ ])
1488+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1489+ ->addTag ('ai.store ' );
14581490
14591491 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
14601492 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1495,8 +1527,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
14951527 }
14961528
14971529 $ definition
1498- ->addTag ('ai.store ' )
1499- ->setArguments ($ arguments );
1530+ ->setLazy (true )
1531+ ->setArguments ($ arguments )
1532+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1533+ ->addTag ('ai.store ' );
15001534
15011535 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
15021536 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1530,11 +1564,14 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
15301564
15311565 $ definition = new Definition (SupabaseStore::class);
15321566 $ definition
1533- ->addTag ('ai.store ' )
1534- ->setArguments ($ arguments );
1567+ ->setLazy (true )
1568+ ->setArguments ($ arguments )
1569+ ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
1570+ ->addTag ('ai.store ' );
15351571
15361572 $ container ->setDefinition ('ai.store.supabase. ' .$ name , $ definition );
1537- $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
1573+ $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
1574+ $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ type .'_ ' .$ name );
15381575 }
15391576 }
15401577 }
@@ -1750,10 +1787,12 @@ private function processChatConfig(string $name, array $configuration, Container
17501787 {
17511788 $ definition = new Definition (Chat::class);
17521789 $ definition
1790+ ->setLazy (true )
17531791 ->setArguments ([
17541792 new Reference ($ configuration ['agent ' ]),
17551793 new Reference ($ configuration ['message_store ' ]),
17561794 ])
1795+ ->addTag ('proxy ' , ['interface ' => ChatInterface::class])
17571796 ->addTag ('ai.chat ' );
17581797
17591798 $ container ->setDefinition ('ai.chat. ' .$ name , $ definition );
0 commit comments