5151use Symfony \AI \Platform \ModelCatalog \ModelCatalogInterface ;
5252use Symfony \AI \Platform \PlatformInterface ;
5353use Symfony \AI \Store \Bridge \AzureSearch \SearchStore as AzureStore ;
54+ use Symfony \AI \Store \Bridge \AzureSearch \StoreFactory as AzureSearchStoreFactory ;
5455use Symfony \AI \Store \Bridge \Cache \Store as CacheStore ;
5556use Symfony \AI \Store \Bridge \ChromaDb \Store as ChromaDbStore ;
5657use Symfony \AI \Store \Bridge \ClickHouse \Store as ClickhouseStore ;
6667use Symfony \AI \Store \Bridge \Postgres \Distance as PostgresDistance ;
6768use Symfony \AI \Store \Bridge \Postgres \Store as PostgresStore ;
6869use Symfony \AI \Store \Bridge \Qdrant \Store as QdrantStore ;
69- use Symfony \AI \Store \Bridge \Qdrant \StoreFactory ;
70+ use Symfony \AI \Store \Bridge \Qdrant \StoreFactory as QdrantStoreFactory ;
7071use Symfony \AI \Store \Bridge \Redis \Distance as RedisDistance ;
7172use Symfony \AI \Store \Bridge \Redis \Store as RedisStore ;
7273use Symfony \AI \Store \Bridge \Supabase \Store as SupabaseStore ;
@@ -477,16 +478,18 @@ public function testAzureStoreCanBeConfigured()
477478 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.azuresearch.my_azuresearch_store ' ));
478479
479480 $ definition = $ container ->getDefinition ('ai.store.azuresearch.my_azuresearch_store ' );
481+ $ this ->assertSame ([AzureSearchStoreFactory::class, 'create ' ], $ definition ->getFactory ());
480482 $ this ->assertSame (AzureStore::class, $ definition ->getClass ());
481-
482483 $ this ->assertTrue ($ definition ->isLazy ());
483- $ this -> assertCount ( 5 , $ definition -> getArguments ());
484- $ this ->assertInstanceOf (Reference::class , $ definition ->getArgument ( 0 ));
485- $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (0 ));
486- $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (1 ));
487- $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (2 ));
488- $ this ->assertSame ('my-documents ' , $ definition ->getArgument (3 ));
484+
485+ $ this ->assertCount ( 6 , $ definition ->getArguments ( ));
486+ $ this ->assertSame ('my-documents ' , (string ) $ definition ->getArgument (0 ));
487+ $ this ->assertSame ('vector ' , $ definition ->getArgument (1 ));
488+ $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (2 ));
489+ $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (3 ));
489490 $ this ->assertSame ('2023-11-01 ' , $ definition ->getArgument (4 ));
491+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (5 ));
492+ $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (5 ));
490493
491494 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
492495 $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
@@ -496,10 +499,8 @@ public function testAzureStoreCanBeConfigured()
496499 $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $myAzuresearchStore ' ));
497500 $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $azuresearchMyAzuresearchStore ' ));
498501 $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class));
499- }
500502
501- public function testAzureStoreCanBeConfiguredWithCustomVectorField ()
502- {
503+ // Custom vector field
503504 $ container = $ this ->buildContainer ([
504505 'ai ' => [
505506 'store ' => [
@@ -519,17 +520,56 @@ public function testAzureStoreCanBeConfiguredWithCustomVectorField()
519520 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.azuresearch.my_azuresearch_store ' ));
520521
521522 $ definition = $ container ->getDefinition ('ai.store.azuresearch.my_azuresearch_store ' );
523+ $ this ->assertSame ([AzureSearchStoreFactory::class, 'create ' ], $ definition ->getFactory ());
522524 $ this ->assertSame (AzureStore::class, $ definition ->getClass ());
523-
524525 $ this ->assertTrue ($ definition ->isLazy ());
526+
525527 $ this ->assertCount (6 , $ definition ->getArguments ());
526- $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
527- $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (0 ));
528- $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (1 ));
529- $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (2 ));
530- $ this ->assertSame ('my-documents ' , $ definition ->getArgument (3 ));
528+ $ this ->assertSame ('my-documents ' , (string ) $ definition ->getArgument (0 ));
529+ $ this ->assertSame ('foo ' , $ definition ->getArgument (1 ));
530+ $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (2 ));
531+ $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (3 ));
531532 $ this ->assertSame ('2023-11-01 ' , $ definition ->getArgument (4 ));
532- $ this ->assertSame ('foo ' , $ definition ->getArgument (5 ));
533+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (5 ));
534+ $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (5 ));
535+
536+ $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
537+ $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
538+ $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
539+
540+ $ this ->assertTrue ($ container ->hasAlias ('. ' .StoreInterface::class.' $my_azuresearch_store ' ));
541+ $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $myAzuresearchStore ' ));
542+ $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $azuresearchMyAzuresearchStore ' ));
543+ $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class));
544+
545+ // Scoped HttpClient
546+ $ container = $ this ->buildContainer ([
547+ 'ai ' => [
548+ 'store ' => [
549+ 'azuresearch ' => [
550+ 'my_azuresearch_store ' => [
551+ 'http_client ' => 'scoped_http_client ' ,
552+ ],
553+ ],
554+ ],
555+ ],
556+ ]);
557+
558+ $ this ->assertTrue ($ container ->hasDefinition ('ai.store.azuresearch.my_azuresearch_store ' ));
559+
560+ $ definition = $ container ->getDefinition ('ai.store.azuresearch.my_azuresearch_store ' );
561+ $ this ->assertSame ([AzureSearchStoreFactory::class, 'create ' ], $ definition ->getFactory ());
562+ $ this ->assertSame (AzureStore::class, $ definition ->getClass ());
563+ $ this ->assertTrue ($ definition ->isLazy ());
564+
565+ $ this ->assertCount (6 , $ definition ->getArguments ());
566+ $ this ->assertSame ('my_azuresearch_store ' , (string ) $ definition ->getArgument (0 ));
567+ $ this ->assertSame ('vector ' , $ definition ->getArgument (1 ));
568+ $ this ->assertNull ($ definition ->getArgument (2 ));
569+ $ this ->assertNull ($ definition ->getArgument (3 ));
570+ $ this ->assertNull ($ definition ->getArgument (4 ));
571+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (5 ));
572+ $ this ->assertSame ('scoped_http_client ' , (string ) $ definition ->getArgument (5 ));
533573
534574 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
535575 $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
@@ -2670,7 +2710,7 @@ public function testQdrantStoreCanBeConfigured()
26702710 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
26712711
26722712 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2673- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2713+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
26742714 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
26752715 $ this ->assertTrue ($ definition ->isLazy ());
26762716
@@ -2714,7 +2754,7 @@ public function testQdrantStoreCanBeConfigured()
27142754 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
27152755
27162756 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2717- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2757+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
27182758 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
27192759 $ this ->assertTrue ($ definition ->isLazy ());
27202760
@@ -2759,7 +2799,7 @@ public function testQdrantStoreCanBeConfigured()
27592799 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
27602800
27612801 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2762- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2802+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
27632803 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
27642804 $ this ->assertTrue ($ definition ->isLazy ());
27652805
@@ -2805,7 +2845,7 @@ public function testQdrantStoreCanBeConfigured()
28052845 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
28062846
28072847 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2808- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2848+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
28092849 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
28102850 $ this ->assertTrue ($ definition ->isLazy ());
28112851
@@ -2848,7 +2888,7 @@ public function testQdrantStoreCanBeConfigured()
28482888 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
28492889
28502890 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2851- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2891+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
28522892 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
28532893 $ this ->assertTrue ($ definition ->isLazy ());
28542894
@@ -7912,6 +7952,9 @@ private function getFullConfig(): array
79127952 'api_version ' => '2023-11-01 ' ,
79137953 'vector_field ' => 'contentVector ' ,
79147954 ],
7955+ 'my_azuresearch_store_with_scoped_http_client ' => [
7956+ 'http_client ' => 'scoped_http_client ' ,
7957+ ],
79157958 ],
79167959 'cache ' => [
79177960 'my_cache_store ' => [
0 commit comments