@@ -246,17 +246,22 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
246
246
{
247
247
if ('azure_search ' === $ type ) {
248
248
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
+
249
260
$ definition = new Definition (AzureSearchStore::class);
250
261
$ definition
251
262
->setAutowired (true )
252
263
->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 );
260
265
261
266
$ container ->setDefinition ('llm_chain.store. ' .$ type .'. ' .$ name , $ definition );
262
267
}
@@ -276,33 +281,49 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
276
281
277
282
if ('mongodb ' === $ type ) {
278
283
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
+
279
298
$ definition = new Definition (MongoDBStore::class);
280
299
$ definition
281
300
->setAutowired (true )
282
301
->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 );
290
303
291
304
$ container ->setDefinition ('llm_chain.store. ' .$ type .'. ' .$ name , $ definition );
292
305
}
293
306
}
294
307
295
308
if ('pinecone ' === $ type ) {
296
309
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
+
297
322
$ definition = new Definition (PineconeStore::class);
298
323
$ definition
299
324
->setAutowired (true )
300
325
->addTag ('llm_chain.store ' )
301
- ->setArguments ([
302
- '$namespace ' => $ store ['namespace ' ],
303
- '$filter ' => $ store ['filter ' ],
304
- '$topK ' => $ store ['top_k ' ],
305
- ]);
326
+ ->setArguments ($ arguments );
306
327
307
328
$ container ->setDefinition ('llm_chain.store. ' .$ type .'. ' .$ name , $ definition );
308
329
}
0 commit comments