From 60cd6250601a38234e45f1bea6660e1777097755 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Wed, 27 Aug 2025 15:52:19 -0400 Subject: [PATCH] Add bundle integration for Voyage --- src/ai-bundle/config/options.php | 5 +++++ src/ai-bundle/src/AiBundle.php | 18 ++++++++++++++++++ .../tests/DependencyInjection/AiBundleTest.php | 3 +++ 3 files changed, 26 insertions(+) diff --git a/src/ai-bundle/config/options.php b/src/ai-bundle/config/options.php index 2b1cbbc64..aa7a78897 100644 --- a/src/ai-bundle/config/options.php +++ b/src/ai-bundle/config/options.php @@ -81,6 +81,11 @@ ->scalarNode('api_key')->isRequired()->end() ->end() ->end() + ->arrayNode('voyage') + ->children() + ->scalarNode('api_key')->isRequired()->end() + ->end() + ->end() ->end() ->end() ->arrayNode('agent') diff --git a/src/ai-bundle/src/AiBundle.php b/src/ai-bundle/src/AiBundle.php index 728d71f4c..9711cb8de 100644 --- a/src/ai-bundle/src/AiBundle.php +++ b/src/ai-bundle/src/AiBundle.php @@ -35,6 +35,7 @@ use Symfony\AI\Platform\Bridge\Ollama\PlatformFactory as OllamaPlatformFactory; use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory as OpenAiPlatformFactory; use Symfony\AI\Platform\Bridge\OpenRouter\PlatformFactory as OpenRouterPlatformFactory; +use Symfony\AI\Platform\Bridge\Voyage\PlatformFactory as VoyagePlatformFactory; use Symfony\AI\Platform\Model; use Symfony\AI\Platform\ModelClientInterface; use Symfony\AI\Platform\Platform; @@ -353,6 +354,23 @@ private function processPlatformConfig(string $type, array $platform, ContainerB return; } + if ('voyage' === $type && isset($platform['api_key'])) { + $platformId = 'ai.platform.voyage'; + $definition = (new Definition(Platform::class)) + ->setFactory(VoyagePlatformFactory::class.'::create') + ->setLazy(true) + ->addTag('proxy', ['interface' => PlatformInterface::class]) + ->setArguments([ + $platform['api_key'], + new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE), + ]) + ->addTag('ai.platform'); + + $container->setDefinition($platformId, $definition); + + return; + } + throw new InvalidArgumentException(\sprintf('Platform "%s" is not supported for configuration via bundle at this point.', $type)); } diff --git a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php index ebe181b64..9ac88e378 100644 --- a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php +++ b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php @@ -326,6 +326,9 @@ private function getFullConfig(): array 'cerebras' => [ 'api_key' => 'cerebras_key_full', ], + 'voyage' => [ + 'api_key' => 'voyage_key_full', + ], ], 'agent' => [ 'my_chat_agent' => [