diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 84bb8f3fa..950673d8d 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -106,6 +106,9 @@ jobs: - run: composer run-script auto-scripts --no-interaction working-directory: demo + - run: bin/console cache:clear + working-directory: demo + - name: Run demo tests working-directory: demo run: vendor/bin/phpunit diff --git a/src/ai-bundle/config/services.php b/src/ai-bundle/config/services.php index 2f4aa5e2c..bb5289196 100644 --- a/src/ai-bundle/config/services.php +++ b/src/ai-bundle/config/services.php @@ -73,7 +73,7 @@ ->factory([OpenAiContract::class, 'create']) ->set('ai.platform.contract.anthropic', Contract::class) ->factory([AnthropicContract::class, 'create']) - ->set('ai.platform.contract.google', Contract::class) + ->set('ai.platform.contract.gemini', Contract::class) ->factory([GeminiContract::class, 'create']) ->set('ai.platform.contract.vertexai.gemini', Contract::class) ->factory([VertexAiGeminiContract::class, 'create']) diff --git a/src/ai-bundle/src/AiBundle.php b/src/ai-bundle/src/AiBundle.php index c5d74a29c..fe6883f8d 100644 --- a/src/ai-bundle/src/AiBundle.php +++ b/src/ai-bundle/src/AiBundle.php @@ -224,8 +224,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.anthropic'), new Reference('ai.platform.model_catalog.anthropic'), + new Reference('ai.platform.contract.anthropic'), ]) ->addTag('ai.platform'); @@ -247,8 +247,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB $config['api_version'], $config['api_key'], new Reference($config['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.openai'), new Reference('ai.platform.model_catalog.azure.openai'), + new Reference('ai.platform.contract.azure.openai'), ]) ->addTag('ai.platform'); @@ -268,8 +268,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB $platform['api_key'], $platform['host'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.default'), new Reference('ai.platform.model_catalog.elevenlabs'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); @@ -287,8 +287,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.google'), new Reference('ai.platform.model_catalog.gemini'), + new Reference('ai.platform.contract.gemini'), ]) ->addTag('ai.platform'); @@ -327,8 +327,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB $platform['location'], $platform['project_id'], $httpClient, - new Reference('ai.platform.contract.vertexai', ContainerInterface::NULL_ON_INVALID_REFERENCE), new Reference('ai.platform.model_catalog.vertexai.gemini'), + new Reference('ai.platform.contract.vertexai.gemini'), ]) ->addTag('ai.platform'); @@ -346,6 +346,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), + new Reference('ai.platform.model_catalog.openai'), new Reference('ai.platform.contract.openai'), $platform['region'] ?? null, ]) @@ -365,8 +366,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.default'), new Reference('ai.platform.model_catalog.openrouter'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); @@ -384,8 +385,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.default'), new Reference('ai.platform.model_catalog.mistral'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); @@ -403,8 +404,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['host_url'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.default'), new Reference('ai.platform.model_catalog.lmstudio'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); @@ -422,8 +423,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['host_url'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.ollama'), new Reference('ai.platform.model_catalog.ollama'), + new Reference('ai.platform.contract.ollama'), ]) ->addTag('ai.platform'); @@ -442,6 +443,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), new Reference('ai.platform.model_catalog.cerebras'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); @@ -460,6 +462,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), new Reference('ai.platform.model_catalog.voyage'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); @@ -477,6 +480,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['api_key'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), + new Reference('ai.platform.model_catalog.perplexity'), new Reference('ai.platform.contract.perplexity'), ]) ->addTag('ai.platform'); @@ -495,8 +499,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['host_url'], new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.default'), new Reference('ai.platform.model_catalog.dockermodelrunner'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); @@ -514,8 +518,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB ->setArguments([ $platform['api_key'], new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE), - new Reference('ai.platform.contract.default'), new Reference('ai.platform.model_catalog.scaleway'), + new Reference('ai.platform.contract.default'), ]) ->addTag('ai.platform'); diff --git a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php index ae0c2b1df..efc53c8f8 100644 --- a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php +++ b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php @@ -606,9 +606,9 @@ public function testOpenAiPlatformWithDefaultRegion() $definition = $container->getDefinition('ai.platform.openai'); $arguments = $definition->getArguments(); - $this->assertCount(4, $arguments); + $this->assertCount(5, $arguments); $this->assertSame('sk-test-key', $arguments[0]); - $this->assertNull($arguments[3]); // region should be null by default + $this->assertNull($arguments[4]); // region should be null by default } #[TestWith(['EU'])] @@ -632,9 +632,9 @@ public function testOpenAiPlatformWithRegion(?string $region) $definition = $container->getDefinition('ai.platform.openai'); $arguments = $definition->getArguments(); - $this->assertCount(4, $arguments); + $this->assertCount(5, $arguments); $this->assertSame('sk-test-key', $arguments[0]); - $this->assertSame($region, $arguments[3]); + $this->assertSame($region, $arguments[4]); } public function testOpenAiPlatformWithInvalidRegion() @@ -671,12 +671,14 @@ public function testPerplexityPlatformConfiguration() $definition = $container->getDefinition('ai.platform.perplexity'); $arguments = $definition->getArguments(); - $this->assertCount(3, $arguments); + $this->assertCount(4, $arguments); $this->assertSame('pplx-test-key', $arguments[0]); $this->assertInstanceOf(Reference::class, $arguments[1]); $this->assertSame('http_client', (string) $arguments[1]); $this->assertInstanceOf(Reference::class, $arguments[2]); - $this->assertSame('ai.platform.contract.perplexity', (string) $arguments[2]); + $this->assertSame('ai.platform.model_catalog.perplexity', (string) $arguments[2]); + $this->assertInstanceOf(Reference::class, $arguments[3]); + $this->assertSame('ai.platform.contract.perplexity', (string) $arguments[3]); } #[TestDox('System prompt with array structure works correctly')] diff --git a/src/platform/src/Bridge/Cerebras/PlatformFactory.php b/src/platform/src/Bridge/Cerebras/PlatformFactory.php index 130a78df0..0063b0660 100644 --- a/src/platform/src/Bridge/Cerebras/PlatformFactory.php +++ b/src/platform/src/Bridge/Cerebras/PlatformFactory.php @@ -11,6 +11,7 @@ namespace Symfony\AI\Platform\Bridge\Cerebras; +use Symfony\AI\Platform\Contract; use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface; use Symfony\AI\Platform\Platform; use Symfony\Component\HttpClient\EventSourceHttpClient; @@ -25,6 +26,7 @@ public static function create( #[\SensitiveParameter] string $apiKey, ?HttpClientInterface $httpClient = null, ModelCatalogInterface $modelCatalog = new ModelCatalog(), + ?Contract $contract = null, ): Platform { $httpClient = $httpClient instanceof EventSourceHttpClient ? $httpClient : new EventSourceHttpClient($httpClient); @@ -32,6 +34,7 @@ public static function create( [new ModelClient($httpClient, $apiKey)], [new ResultConverter()], $modelCatalog, + $contract, ); } } diff --git a/src/platform/src/Bridge/Voyage/PlatformFactory.php b/src/platform/src/Bridge/Voyage/PlatformFactory.php index f6a652a4f..9af30c15a 100644 --- a/src/platform/src/Bridge/Voyage/PlatformFactory.php +++ b/src/platform/src/Bridge/Voyage/PlatformFactory.php @@ -30,6 +30,11 @@ public static function create( ): Platform { $httpClient = $httpClient instanceof EventSourceHttpClient ? $httpClient : new EventSourceHttpClient($httpClient); - return new Platform([new ModelClient($httpClient, $apiKey)], [new ResultConverter()], $modelCatalog, $contract); + return new Platform( + [new ModelClient($httpClient, $apiKey)], + [new ResultConverter()], + $modelCatalog, + $contract, + ); } }