@@ -1050,18 +1050,12 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10501050 $ store ['account_id ' ],
10511051 $ store ['api_key ' ],
10521052 $ store ['index_name ' ],
1053+ $ store ['dimensions ' ],
1054+ $ store ['metric ' ],
10531055 ];
10541056
1055- if (\array_key_exists ('dimensions ' , $ store )) {
1056- $ arguments [4 ] = $ store ['dimensions ' ];
1057- }
1058-
1059- if (\array_key_exists ('metric ' , $ store )) {
1060- $ arguments [5 ] = $ store ['metric ' ];
1061- }
1062-
1063- if (\array_key_exists ('endpoint ' , $ store )) {
1064- $ arguments [6 ] = $ store ['endpoint ' ];
1057+ if (\array_key_exists ('endpoint_url ' , $ store )) {
1058+ $ arguments [6 ] = $ store ['endpoint_url ' ];
10651059 }
10661060
10671061 $ definition = new Definition (CloudflareStore::class);
@@ -1084,35 +1078,23 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
10841078 new Reference ('http_client ' ),
10851079 $ store ['endpoint ' ],
10861080 $ store ['table ' ],
1081+ $ store ['field ' ],
1082+ $ store ['type ' ],
1083+ $ store ['similarity ' ],
1084+ $ store ['dimensions ' ],
10871085 ];
10881086
1089- if (\array_key_exists ('field ' , $ store )) {
1090- $ arguments [3 ] = $ store ['field ' ];
1091- }
1092-
1093- if (\array_key_exists ('type ' , $ store )) {
1094- $ arguments [4 ] = $ store ['type ' ];
1095- }
1096-
1097- if (\array_key_exists ('similarity ' , $ store )) {
1098- $ arguments [5 ] = $ store ['similarity ' ];
1099- }
1100-
1101- if (\array_key_exists ('dimensions ' , $ store )) {
1102- $ arguments [6 ] = $ store ['dimensions ' ];
1103- }
1104-
11051087 if (\array_key_exists ('quantization ' , $ store )) {
11061088 $ arguments [7 ] = $ store ['quantization ' ];
11071089 }
11081090
11091091 $ definition = new Definition (ManticoreStore::class);
11101092 $ definition
11111093 ->setLazy (true )
1112- ->addTag ( ' ai.store ' )
1094+ ->setArguments ( $ arguments )
11131095 ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
11141096 ->addTag ('proxy ' , ['interface ' => ManagedStoreInterface::class])
1115- ->setArguments ( $ arguments );
1097+ ->addTag ( ' ai.store ' );
11161098
11171099 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
11181100 $ container ->registerAliasForArgument ('ai.store. ' .$ type .'. ' .$ name , StoreInterface::class, $ name );
@@ -1122,18 +1104,16 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11221104
11231105 if ('mariadb ' === $ type ) {
11241106 foreach ($ stores as $ name => $ store ) {
1125- $ arguments = [
1126- new Reference (\sprintf ('doctrine.dbal.%s_connection ' , $ store ['connection ' ])),
1127- $ store ['table_name ' ],
1128- $ store ['index_name ' ],
1129- $ store ['vector_field_name ' ],
1130- ];
1131-
11321107 $ definition = new Definition (MariaDbStore::class);
11331108 $ definition ->setFactory ([MariaDbStore::class, 'fromDbal ' ]);
11341109 $ definition
11351110 ->setLazy (true )
1136- ->setArguments ($ arguments )
1111+ ->setArguments ([
1112+ new Reference (\sprintf ('doctrine.dbal.%s_connection ' , $ store ['connection ' ])),
1113+ $ store ['table_name ' ],
1114+ $ store ['index_name ' ],
1115+ $ store ['vector_field_name ' ],
1116+ ])
11371117 ->addTag ('proxy ' , ['interface ' => StoreInterface::class])
11381118 ->addTag ('proxy ' , ['interface ' => ManagedStoreInterface::class])
11391119 ->addTag ('ai.store ' );
@@ -1154,20 +1134,11 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11541134 $ store ['endpoint ' ],
11551135 $ store ['api_key ' ],
11561136 $ store ['index_name ' ],
1137+ $ store ['embedder ' ],
1138+ $ store ['vector_field ' ],
1139+ $ store ['dimensions ' ],
11571140 ];
11581141
1159- if (\array_key_exists ('embedder ' , $ store )) {
1160- $ arguments [4 ] = $ store ['embedder ' ];
1161- }
1162-
1163- if (\array_key_exists ('vector_field ' , $ store )) {
1164- $ arguments [5 ] = $ store ['vector_field ' ];
1165- }
1166-
1167- if (\array_key_exists ('dimensions ' , $ store )) {
1168- $ arguments [6 ] = $ store ['dimensions ' ];
1169- }
1170-
11711142 if (\array_key_exists ('semantic_ratio ' , $ store )) {
11721143 $ arguments [7 ] = $ store ['semantic_ratio ' ];
11731144 }
@@ -1193,12 +1164,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11931164 ];
11941165
11951166 if (\array_key_exists ('strategy ' , $ store ) && null !== $ store ['strategy ' ]) {
1196- if (!$ container ->hasDefinition ('ai.store.distance_calculator. ' .$ name )) {
1197- $ distanceCalculatorDefinition = new Definition (DistanceCalculator::class);
1198- $ distanceCalculatorDefinition ->setArgument (0 , DistanceStrategy::from ($ store ['strategy ' ]));
1167+ $ distanceCalculatorDefinition = new Definition (DistanceCalculator::class);
1168+ $ distanceCalculatorDefinition ->setArgument (0 , DistanceStrategy::from ($ store ['strategy ' ]));
11991169
1200- $ container ->setDefinition ('ai.store.distance_calculator. ' .$ name , $ distanceCalculatorDefinition );
1201- }
1170+ $ container ->setDefinition ('ai.store.distance_calculator. ' .$ name , $ distanceCalculatorDefinition );
12021171
12031172 $ arguments [0 ] = new Reference ('ai.store.distance_calculator. ' .$ name );
12041173 }
@@ -1225,16 +1194,10 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
12251194 $ store ['api_key ' ],
12261195 $ store ['database ' ],
12271196 $ store ['collection ' ],
1197+ $ store ['vector_field ' ],
1198+ $ store ['dimensions ' ],
12281199 ];
12291200
1230- if (\array_key_exists ('vector_field ' , $ store )) {
1231- $ arguments [5 ] = $ store ['vector_field ' ];
1232- }
1233-
1234- if (\array_key_exists ('dimensions ' , $ store )) {
1235- $ arguments [6 ] = $ store ['dimensions ' ];
1236- }
1237-
12381201 if (\array_key_exists ('metric_type ' , $ store )) {
12391202 $ arguments [7 ] = $ store ['metric_type ' ];
12401203 }
0 commit comments