|
55 | 55 | use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory as AnthropicPlatformFactory; |
56 | 56 | use Symfony\AI\Platform\Bridge\Azure\OpenAi\PlatformFactory as AzureOpenAiPlatformFactory; |
57 | 57 | use Symfony\AI\Platform\Bridge\Bedrock\PlatformFactory as BedrockFactory; |
| 58 | +use Symfony\AI\Platform\Bridge\Cache\CachePlatform; |
58 | 59 | use Symfony\AI\Platform\Bridge\Cartesia\PlatformFactory as CartesiaPlatformFactory; |
59 | 60 | use Symfony\AI\Platform\Bridge\Cerebras\PlatformFactory as CerebrasPlatformFactory; |
60 | 61 | use Symfony\AI\Platform\Bridge\Decart\PlatformFactory as DecartPlatformFactory; |
|
78 | 79 | use Symfony\AI\Platform\Bridge\TransformersPhp\PlatformFactory as TransformersPhpPlatformFactory; |
79 | 80 | use Symfony\AI\Platform\Bridge\VertexAi\PlatformFactory as VertexAiPlatformFactory; |
80 | 81 | use Symfony\AI\Platform\Bridge\Voyage\PlatformFactory as VoyagePlatformFactory; |
81 | | -use Symfony\AI\Platform\CachedPlatform; |
82 | 82 | use Symfony\AI\Platform\Capability; |
83 | 83 | use Symfony\AI\Platform\Exception\RuntimeException; |
84 | 84 | use Symfony\AI\Platform\Message\Content\File; |
@@ -514,20 +514,26 @@ private function processPlatformConfig(string $type, array $platform, ContainerB |
514 | 514 | } |
515 | 515 |
|
516 | 516 | if ('cache' === $type) { |
517 | | - foreach ($platform as $name => $cachedPlatformConfig) { |
518 | | - $definition = (new Definition(CachedPlatform::class)) |
| 517 | + foreach ($platform as $name => $cachePlatformConfig) { |
| 518 | + if (!ContainerBuilder::willBeAvailable('symfony/ai-cache-platform', CachePlatform::class, ['symfony/ai-bundle'])) { |
| 519 | + throw new RuntimeException('CachePlatform platform configuration requires "symfony/ai-cache-platform" package. Try running "composer require symfony/ai-cache-platform".'); |
| 520 | + } |
| 521 | + |
| 522 | + $definition = (new Definition(CachePlatform::class)) |
519 | 523 | ->setLazy(true) |
520 | 524 | ->setArguments([ |
521 | | - new Reference($cachedPlatformConfig['platform']), |
| 525 | + new Reference($cachePlatformConfig['platform']), |
522 | 526 | new Reference(ClockInterface::class), |
523 | | - new Reference($cachedPlatformConfig['service'], ContainerInterface::NULL_ON_INVALID_REFERENCE), |
524 | | - $cachedPlatformConfig['cache_key'] ?? $name, |
| 527 | + new Reference($cachePlatformConfig['service'], ContainerInterface::NULL_ON_INVALID_REFERENCE), |
| 528 | + new Reference('serializer'), |
| 529 | + $cachePlatformConfig['cache_key'] ?? $name, |
| 530 | + $cachePlatformConfig['ttl'] ?? null, |
525 | 531 | ]) |
526 | 532 | ->addTag('proxy', ['interface' => PlatformInterface::class]) |
527 | 533 | ->addTag('ai.platform', ['name' => 'cache.'.$name]); |
528 | 534 |
|
529 | | - $container->setDefinition('ai.platform.cache.'.$name, $definition); |
530 | | - $container->registerAliasForArgument('ai.platform.'.$type, PlatformInterface::class, $type.'_'.$name); |
| 535 | + $container->setDefinition('ai.platform.'.$type.'.'.$name, $definition); |
| 536 | + $container->registerAliasForArgument('ai.platform.'.$type.'.'.$name, PlatformInterface::class, $type.'_'.$name); |
531 | 537 | } |
532 | 538 |
|
533 | 539 | return; |
|
0 commit comments