<?php
namespace App\AI\SymfonyAiExtend\Gemini; use Symfony\AI\Platform\Bridge\Gemini\Contract\GeminiContract; use Symfony\AI\Platform\Bridge\Gemini\ModelCatalog; use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface; use Symfony\AI\Platform\ModelRouter\CatalogBasedModelRouter; use Symfony\AI\Platform\ModelRouterInterface; use Symfony\AI\Platform\Platform; use Symfony\AI\Platform\Provider; use Symfony\Component\HttpClient\EventSourceHttpClient; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; final class InteractionsFactory { public static function createPlatform( #[\SensitiveParameter] string $apiKey, ?HttpClientInterface $httpClient = null, ModelCatalogInterface $modelCatalog = new ModelCatalog(), ?EventDispatcherInterface $eventDispatcher = null, string $name = 'gemini-interactions', ?ModelRouterInterface $modelRouter = null, ): Platform { $httpClient = $httpClient instanceof EventSourceHttpClient ? $httpClient : new EventSourceHttpClient($httpClient); $provider = new Provider( $name, [new InteractionsModelClient($httpClient, $apiKey)], [new InteractionsResultConverter()], $modelCatalog, GeminiContract::create(), $eventDispatcher, ); return new Platform( [$provider], $modelRouter ?? new CatalogBasedModelRouter(), $eventDispatcher, ); } } 