@@ -328,6 +328,10 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
328328 private function processPlatformConfig (string $ type , array $ platform , ContainerBuilder $ container ): void
329329 {
330330 if ('albert ' === $ type ) {
331+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-albert-platform ' , AlbertPlatformFactory::class, ['symfony/ai-bundle ' ])) {
332+ throw new RuntimeException ('Albert platform configuration requires "symfony/ai-albert-platform" package. Try running "composer require symfony/ai-albert-platform". ' );
333+ }
334+
331335 $ platformId = 'ai.platform.albert ' ;
332336 $ definition = (new Definition (Platform::class))
333337 ->setFactory (AlbertPlatformFactory::class.'::create ' )
@@ -348,6 +352,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
348352 }
349353
350354 if ('anthropic ' === $ type ) {
355+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-anthropic-platform ' , AnthropicPlatformFactory::class, ['symfony/ai-bundle ' ])) {
356+ throw new RuntimeException ('Anthropic platform configuration requires "symfony/ai-anthropic-platform" package. Try running "composer require symfony/ai-anthropic-platform". ' );
357+ }
358+
351359 $ platformId = 'ai.platform.anthropic ' ;
352360 $ definition = (new Definition (Platform::class))
353361 ->setFactory (AnthropicPlatformFactory::class.'::create ' )
@@ -368,6 +376,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
368376 }
369377
370378 if ('azure ' === $ type ) {
379+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-azure-platform ' , AzureOpenAiPlatformFactory::class, ['symfony/ai-bundle ' ])) {
380+ throw new RuntimeException ('Azure platform configuration requires "symfony/ai-azure-platform" package. Try running "composer require symfony/ai-azure-platform". ' );
381+ }
382+
371383 foreach ($ platform as $ name => $ config ) {
372384 $ platformId = 'ai.platform.azure. ' .$ name ;
373385 $ definition = (new Definition (Platform::class))
@@ -411,6 +423,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
411423 }
412424
413425 if ('cartesia ' === $ type ) {
426+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-cartesia-platform ' , CartesiaPlatformFactory::class, ['symfony/ai-bundle ' ])) {
427+ throw new RuntimeException ('Cartesia platform configuration requires "symfony/ai-cartesia-platform" package. Try running "composer require symfony/ai-cartesia-platform". ' );
428+ }
429+
414430 $ definition = (new Definition (Platform::class))
415431 ->setFactory (CartesiaPlatformFactory::class.'::create ' )
416432 ->setLazy (true )
@@ -431,6 +447,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
431447 }
432448
433449 if ('elevenlabs ' === $ type ) {
450+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-eleven-labs-platform ' , ElevenLabsPlatformFactory::class, ['symfony/ai-bundle ' ])) {
451+ throw new RuntimeException ('ElevenLabs platform configuration requires "symfony/ai-eleven-labs-platform" package. Try running "composer require symfony/ai-eleven-labs-platform". ' );
452+ }
453+
434454 $ definition = (new Definition (Platform::class))
435455 ->setFactory (ElevenLabsPlatformFactory::class.'::create ' )
436456 ->setLazy (true )
@@ -452,6 +472,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
452472 }
453473
454474 if ('gemini ' === $ type ) {
475+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-gemini-platform ' , GeminiPlatformFactory::class, ['symfony/ai-bundle ' ])) {
476+ throw new RuntimeException ('Gemini platform configuration requires "symfony/ai-gemini-platform" package. Try running "composer require symfony/ai-gemini-platform". ' );
477+ }
478+
455479 $ platformId = 'ai.platform.gemini ' ;
456480 $ definition = (new Definition (Platform::class))
457481 ->setFactory (GeminiPlatformFactory::class.'::create ' )
@@ -472,6 +496,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
472496 }
473497
474498 if ('generic ' === $ type ) {
499+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-generic-platform ' , GenericPlatformFactory::class, ['symfony/ai-bundle ' ])) {
500+ throw new RuntimeException ('Generic platform configuration requires "symfony/ai-generic-platform" package. Try running "composer require symfony/ai-generic-platform". ' );
501+ }
502+
475503 foreach ($ platform as $ name => $ config ) {
476504 $ platformId = 'ai.platform.generic. ' .$ name ;
477505 $ definition = (new Definition (Platform::class))
@@ -499,6 +527,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
499527 }
500528
501529 if ('huggingface ' === $ type ) {
530+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-hugging-face-platform ' , HuggingFacePlatformFactory::class, ['symfony/ai-bundle ' ])) {
531+ throw new RuntimeException ('HuggingFace platform configuration requires "symfony/ai-hugging-face-platform" package. Try running "composer require symfony/ai-hugging-face-platform". ' );
532+ }
533+
502534 $ platformId = 'ai.platform.huggingface ' ;
503535 $ definition = (new Definition (Platform::class))
504536 ->setFactory (HuggingFacePlatformFactory::class.'::create ' )
@@ -520,6 +552,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
520552 }
521553
522554 if ('vertexai ' === $ type && isset ($ platform ['location ' ], $ platform ['project_id ' ])) {
555+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-vertex-ai-platform ' , VertexAiPlatformFactory::class, ['symfony/ai-bundle ' ])) {
556+ throw new RuntimeException ('VertexAI platform configuration requires "symfony/ai-vertex-ai-platform" package. Try running "composer require symfony/ai-vertex-ai-platform". ' );
557+ }
558+
523559 if (!class_exists (ApplicationDefaultCredentials::class)) {
524560 throw new RuntimeException ('For using the Vertex AI platform, google/auth package is required. Try running "composer require google/auth". ' );
525561 }
@@ -561,6 +597,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
561597 }
562598
563599 if ('openai ' === $ type ) {
600+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-open-ai-platform ' , OpenAiPlatformFactory::class, ['symfony/ai-bundle ' ])) {
601+ throw new RuntimeException ('OpenAI platform configuration requires "symfony/ai-open-ai-platform" package. Try running "composer require symfony/ai-open-ai-platform". ' );
602+ }
603+
564604 $ platformId = 'ai.platform.openai ' ;
565605 $ definition = (new Definition (Platform::class))
566606 ->setFactory (OpenAiPlatformFactory::class.'::create ' )
@@ -582,6 +622,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
582622 }
583623
584624 if ('openrouter ' === $ type ) {
625+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-open-router-platform ' , OpenRouterPlatformFactory::class, ['symfony/ai-bundle ' ])) {
626+ throw new RuntimeException ('OpenRouter platform configuration requires "symfony/ai-open-router-platform" package. Try running "composer require symfony/ai-open-router-platform". ' );
627+ }
628+
585629 $ platformId = 'ai.platform.openrouter ' ;
586630 $ definition = (new Definition (Platform::class))
587631 ->setFactory (OpenRouterPlatformFactory::class.'::create ' )
@@ -602,6 +646,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
602646 }
603647
604648 if ('mistral ' === $ type ) {
649+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-mistral-platform ' , MistralPlatformFactory::class, ['symfony/ai-bundle ' ])) {
650+ throw new RuntimeException ('Mistral platform configuration requires "symfony/ai-mistral-platform" package. Try running "composer require symfony/ai-mistral-platform". ' );
651+ }
652+
605653 $ platformId = 'ai.platform.mistral ' ;
606654 $ definition = (new Definition (Platform::class))
607655 ->setFactory (MistralPlatformFactory::class.'::create ' )
@@ -622,6 +670,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
622670 }
623671
624672 if ('lmstudio ' === $ type ) {
673+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-lm-studio-platform ' , LmStudioPlatformFactory::class, ['symfony/ai-bundle ' ])) {
674+ throw new RuntimeException ('LmStudio platform configuration requires "symfony/ai-lm-studio-platform" package. Try running "composer require symfony/ai-lm-studio-platform". ' );
675+ }
676+
625677 $ platformId = 'ai.platform.lmstudio ' ;
626678 $ definition = (new Definition (Platform::class))
627679 ->setFactory (LmStudioPlatformFactory::class.'::create ' )
@@ -642,6 +694,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
642694 }
643695
644696 if ('ollama ' === $ type ) {
697+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-ollama-platform ' , OllamaPlatformFactory::class, ['symfony/ai-bundle ' ])) {
698+ throw new RuntimeException ('Ollama platform configuration requires "symfony/ai-ollama-platform" package. Try running "composer require symfony/ai-ollama-platform". ' );
699+ }
700+
645701 if (\array_key_exists ('api_catalog ' , $ platform )) {
646702 $ catalogDefinition = (new Definition (OllamaApiCatalog::class))
647703 ->setLazy (true )
@@ -672,6 +728,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
672728 }
673729
674730 if ('cerebras ' === $ type ) {
731+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-cerebras-platform ' , CerebrasPlatformFactory::class, ['symfony/ai-bundle ' ])) {
732+ throw new RuntimeException ('Cerebras platform configuration requires "symfony/ai-cerebras-platform" package. Try running "composer require symfony/ai-cerebras-platform". ' );
733+ }
734+
675735 $ platformId = 'ai.platform.cerebras ' ;
676736 $ definition = (new Definition (Platform::class))
677737 ->setFactory (CerebrasPlatformFactory::class.'::create ' )
@@ -692,6 +752,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
692752 }
693753
694754 if ('deepseek ' === $ type ) {
755+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-deep-seek-platform ' , DeepSeekPlatformFactory::class, ['symfony/ai-bundle ' ])) {
756+ throw new RuntimeException ('DeepSeek platform configuration requires "symfony/ai-deep-seek-platform" package. Try running "composer require symfony/ai-deep-seek-platform". ' );
757+ }
758+
695759 $ platformId = 'ai.platform.deepseek ' ;
696760 $ definition = (new Definition (Platform::class))
697761 ->setFactory (DeepSeekPlatformFactory::class.'::create ' )
@@ -712,6 +776,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
712776 }
713777
714778 if ('voyage ' === $ type ) {
779+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-voyage-platform ' , VoyagePlatformFactory::class, ['symfony/ai-bundle ' ])) {
780+ throw new RuntimeException ('Voyage platform configuration requires "symfony/ai-voyage-platform" package. Try running "composer require symfony/ai-voyage-platform". ' );
781+ }
782+
715783 $ platformId = 'ai.platform.voyage ' ;
716784 $ definition = (new Definition (Platform::class))
717785 ->setFactory (VoyagePlatformFactory::class.'::create ' )
@@ -732,6 +800,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
732800 }
733801
734802 if ('perplexity ' === $ type ) {
803+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-perplexity-platform ' , PerplexityPlatformFactory::class, ['symfony/ai-bundle ' ])) {
804+ throw new RuntimeException ('Perplexity platform configuration requires "symfony/ai-perplexity-platform" package. Try running "composer require symfony/ai-perplexity-platform". ' );
805+ }
806+
735807 $ platformId = 'ai.platform.perplexity ' ;
736808 $ definition = (new Definition (Platform::class))
737809 ->setFactory (PerplexityPlatformFactory::class.'::create ' )
@@ -752,6 +824,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
752824 }
753825
754826 if ('dockermodelrunner ' === $ type ) {
827+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-docker-model-runner-platform ' , DockerModelRunnerPlatformFactory::class, ['symfony/ai-bundle ' ])) {
828+ throw new RuntimeException ('Docker Model Runner platform configuration requires "symfony/ai-docker-model-runner-platform" package. Try running "composer require symfony/ai-docker-model-runner-platform". ' );
829+ }
830+
755831 $ platformId = 'ai.platform.dockermodelrunner ' ;
756832 $ definition = (new Definition (Platform::class))
757833 ->setFactory (DockerModelRunnerPlatformFactory::class.'::create ' )
@@ -772,6 +848,10 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
772848 }
773849
774850 if ('scaleway ' === $ type && isset ($ platform ['api_key ' ])) {
851+ if (!ContainerBuilder::willBeAvailable ('symfony/ai-scaleway-platform ' , ScalewayPlatformFactory::class, ['symfony/ai-bundle ' ])) {
852+ throw new RuntimeException ('Scaleway platform configuration requires "symfony/ai-scaleway-platform" package. Try running "composer require symfony/ai-scaleway-platform". ' );
853+ }
854+
775855 $ platformId = 'ai.platform.scaleway ' ;
776856 $ definition = (new Definition (Platform::class))
777857 ->setFactory (ScalewayPlatformFactory::class.'::create ' )
0 commit comments