@@ -246,17 +246,22 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
246246 {
247247 if ('azure_search ' === $ type ) {
248248 foreach ($ stores as $ name => $ store ) {
249+ $ arguments = [
250+ '$endpointUrl ' => $ store ['endpoint ' ],
251+ '$apiKey ' => $ store ['api_key ' ],
252+ '$indexName ' => $ store ['index_name ' ],
253+ '$apiVersion ' => $ store ['api_version ' ],
254+ ];
255+
256+ if (array_key_exists ('vector_field ' , $ store )) {
257+ $ arguments ['$vectorFieldName ' ] = $ store ['vector_field ' ];
258+ }
259+
249260 $ definition = new Definition (AzureSearchStore::class);
250261 $ definition
251262 ->setAutowired (true )
252263 ->addTag ('llm_chain.store ' )
253- ->setArguments ([
254- '$endpointUrl ' => $ store ['endpoint ' ],
255- '$apiKey ' => $ store ['api_key ' ],
256- '$indexName ' => $ store ['index_name ' ],
257- '$apiVersion ' => $ store ['api_version ' ],
258- '$vectorFieldName ' => $ store ['vector_field ' ],
259- ]);
264+ ->setArguments ($ arguments );
260265
261266 $ container ->setDefinition ('llm_chain.store. ' .$ type .'. ' .$ name , $ definition );
262267 }
@@ -276,33 +281,49 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
276281
277282 if ('mongodb ' === $ type ) {
278283 foreach ($ stores as $ name => $ store ) {
284+ $ arguments = [
285+ '$databaseName ' => $ store ['database ' ],
286+ '$collectionName ' => $ store ['collection ' ],
287+ '$indexName ' => $ store ['index_name ' ],
288+ ];
289+
290+ if (array_key_exists ('vector_field ' , $ store )) {
291+ $ arguments ['$vectorFieldName ' ] = $ store ['vector_field ' ];
292+ }
293+
294+ if (array_key_exists ('bulk_write ' , $ store )) {
295+ $ arguments ['$bulkWrite ' ] = $ store ['bulk_write ' ];
296+ }
297+
279298 $ definition = new Definition (MongoDBStore::class);
280299 $ definition
281300 ->setAutowired (true )
282301 ->addTag ('llm_chain.store ' )
283- ->setArguments ([
284- '$databaseName ' => $ store ['database ' ],
285- '$collectionName ' => $ store ['collection ' ],
286- '$indexName ' => $ store ['index_name ' ],
287- '$vectorFieldName ' => $ store ['vector_field ' ],
288- '$bulkWrite ' => $ store ['bulk_write ' ],
289- ]);
302+ ->setArguments ($ arguments );
290303
291304 $ container ->setDefinition ('llm_chain.store. ' .$ type .'. ' .$ name , $ definition );
292305 }
293306 }
294307
295308 if ('pinecone ' === $ type ) {
296309 foreach ($ stores as $ name => $ store ) {
310+ $ arguments = [
311+ '$namespace ' => $ store ['namespace ' ],
312+ ];
313+
314+ if (array_key_exists ('filter ' , $ store )) {
315+ $ arguments ['$filter ' ] = $ store ['filter ' ];
316+ }
317+
318+ if (array_key_exists ('top_k ' , $ store )) {
319+ $ arguments ['$topK ' ] = $ store ['top_k ' ];
320+ }
321+
297322 $ definition = new Definition (PineconeStore::class);
298323 $ definition
299324 ->setAutowired (true )
300325 ->addTag ('llm_chain.store ' )
301- ->setArguments ([
302- '$namespace ' => $ store ['namespace ' ],
303- '$filter ' => $ store ['filter ' ],
304- '$topK ' => $ store ['top_k ' ],
305- ]);
326+ ->setArguments ($ arguments );
306327
307328 $ container ->setDefinition ('llm_chain.store. ' .$ type .'. ' .$ name , $ definition );
308329 }
0 commit comments