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 ;
@@ -485,16 +486,18 @@ public function testAzureStoreCanBeConfigured()
485486 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.azuresearch.my_azuresearch_store ' ));
486487
487488 $ definition = $ container ->getDefinition ('ai.store.azuresearch.my_azuresearch_store ' );
489+ $ this ->assertSame ([AzureSearchStoreFactory::class, 'create ' ], $ definition ->getFactory ());
488490 $ this ->assertSame (AzureStore::class, $ definition ->getClass ());
489-
490491 $ this ->assertTrue ($ definition ->isLazy ());
491- $ this -> assertCount ( 5 , $ definition -> getArguments ());
492- $ this ->assertInstanceOf (Reference::class , $ definition ->getArgument ( 0 ));
493- $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (0 ));
494- $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (1 ));
495- $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (2 ));
496- $ this ->assertSame ('my-documents ' , $ definition ->getArgument (3 ));
492+
493+ $ this ->assertCount ( 6 , $ definition ->getArguments ( ));
494+ $ this ->assertSame ('my-documents ' , (string ) $ definition ->getArgument (0 ));
495+ $ this ->assertSame ('vector ' , $ definition ->getArgument (1 ));
496+ $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (2 ));
497+ $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (3 ));
497498 $ this ->assertSame ('2023-11-01 ' , $ definition ->getArgument (4 ));
499+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (5 ));
500+ $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (5 ));
498501
499502 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
500503 $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
@@ -504,10 +507,8 @@ public function testAzureStoreCanBeConfigured()
504507 $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $myAzuresearchStore ' ));
505508 $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $azuresearchMyAzuresearchStore ' ));
506509 $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class));
507- }
508510
509- public function testAzureStoreCanBeConfiguredWithCustomVectorField ()
510- {
511+ // Custom vector field
511512 $ container = $ this ->buildContainer ([
512513 'ai ' => [
513514 'store ' => [
@@ -527,17 +528,56 @@ public function testAzureStoreCanBeConfiguredWithCustomVectorField()
527528 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.azuresearch.my_azuresearch_store ' ));
528529
529530 $ definition = $ container ->getDefinition ('ai.store.azuresearch.my_azuresearch_store ' );
531+ $ this ->assertSame ([AzureSearchStoreFactory::class, 'create ' ], $ definition ->getFactory ());
530532 $ this ->assertSame (AzureStore::class, $ definition ->getClass ());
531-
532533 $ this ->assertTrue ($ definition ->isLazy ());
534+
533535 $ this ->assertCount (6 , $ definition ->getArguments ());
534- $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
535- $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (0 ));
536- $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (1 ));
537- $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (2 ));
538- $ this ->assertSame ('my-documents ' , $ definition ->getArgument (3 ));
536+ $ this ->assertSame ('my-documents ' , (string ) $ definition ->getArgument (0 ));
537+ $ this ->assertSame ('foo ' , $ definition ->getArgument (1 ));
538+ $ this ->assertSame ('https://mysearch.search.windows.net ' , $ definition ->getArgument (2 ));
539+ $ this ->assertSame ('azure_search_key ' , $ definition ->getArgument (3 ));
539540 $ this ->assertSame ('2023-11-01 ' , $ definition ->getArgument (4 ));
540- $ this ->assertSame ('foo ' , $ definition ->getArgument (5 ));
541+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (5 ));
542+ $ this ->assertSame ('http_client ' , (string ) $ definition ->getArgument (5 ));
543+
544+ $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
545+ $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
546+ $ this ->assertTrue ($ definition ->hasTag ('ai.store ' ));
547+
548+ $ this ->assertTrue ($ container ->hasAlias ('. ' .StoreInterface::class.' $my_azuresearch_store ' ));
549+ $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $myAzuresearchStore ' ));
550+ $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $azuresearchMyAzuresearchStore ' ));
551+ $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class));
552+
553+ // Scoped HttpClient
554+ $ container = $ this ->buildContainer ([
555+ 'ai ' => [
556+ 'store ' => [
557+ 'azuresearch ' => [
558+ 'my_azuresearch_store ' => [
559+ 'http_client ' => 'scoped_http_client ' ,
560+ ],
561+ ],
562+ ],
563+ ],
564+ ]);
565+
566+ $ this ->assertTrue ($ container ->hasDefinition ('ai.store.azuresearch.my_azuresearch_store ' ));
567+
568+ $ definition = $ container ->getDefinition ('ai.store.azuresearch.my_azuresearch_store ' );
569+ $ this ->assertSame ([AzureSearchStoreFactory::class, 'create ' ], $ definition ->getFactory ());
570+ $ this ->assertSame (AzureStore::class, $ definition ->getClass ());
571+ $ this ->assertTrue ($ definition ->isLazy ());
572+
573+ $ this ->assertCount (6 , $ definition ->getArguments ());
574+ $ this ->assertSame ('my_azuresearch_store ' , (string ) $ definition ->getArgument (0 ));
575+ $ this ->assertSame ('vector ' , $ definition ->getArgument (1 ));
576+ $ this ->assertNull ($ definition ->getArgument (2 ));
577+ $ this ->assertNull ($ definition ->getArgument (3 ));
578+ $ this ->assertNull ($ definition ->getArgument (4 ));
579+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (5 ));
580+ $ this ->assertSame ('scoped_http_client ' , (string ) $ definition ->getArgument (5 ));
541581
542582 $ this ->assertTrue ($ definition ->hasTag ('proxy ' ));
543583 $ this ->assertSame ([['interface ' => StoreInterface::class]], $ definition ->getTag ('proxy ' ));
@@ -2678,7 +2718,7 @@ public function testQdrantStoreCanBeConfigured()
26782718 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
26792719
26802720 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2681- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2721+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
26822722 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
26832723 $ this ->assertTrue ($ definition ->isLazy ());
26842724
@@ -2722,7 +2762,7 @@ public function testQdrantStoreCanBeConfigured()
27222762 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
27232763
27242764 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2725- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2765+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
27262766 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
27272767 $ this ->assertTrue ($ definition ->isLazy ());
27282768
@@ -2767,7 +2807,7 @@ public function testQdrantStoreCanBeConfigured()
27672807 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
27682808
27692809 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2770- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2810+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
27712811 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
27722812 $ this ->assertTrue ($ definition ->isLazy ());
27732813
@@ -2813,7 +2853,7 @@ public function testQdrantStoreCanBeConfigured()
28132853 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
28142854
28152855 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2816- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2856+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
28172857 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
28182858 $ this ->assertTrue ($ definition ->isLazy ());
28192859
@@ -2856,7 +2896,7 @@ public function testQdrantStoreCanBeConfigured()
28562896 $ this ->assertTrue ($ container ->hasDefinition ('ai.store.qdrant.my_qdrant_store ' ));
28572897
28582898 $ definition = $ container ->getDefinition ('ai.store.qdrant.my_qdrant_store ' );
2859- $ this ->assertSame ([StoreFactory ::class, 'create ' ], $ definition ->getFactory ());
2899+ $ this ->assertSame ([QdrantStoreFactory ::class, 'create ' ], $ definition ->getFactory ());
28602900 $ this ->assertSame (QdrantStore::class, $ definition ->getClass ());
28612901 $ this ->assertTrue ($ definition ->isLazy ());
28622902
@@ -7920,6 +7960,9 @@ private function getFullConfig(): array
79207960 'api_version ' => '2023-11-01 ' ,
79217961 'vector_field ' => 'contentVector ' ,
79227962 ],
7963+ 'my_azuresearch_store_with_scoped_http_client ' => [
7964+ 'http_client ' => 'scoped_http_client ' ,
7965+ ],
79237966 ],
79247967 'cache ' => [
79257968 'my_cache_store ' => [
0 commit comments