|
27 | 27 | use Symfony\AI\AIBundle\Profiler\DataCollector; |
28 | 28 | use Symfony\AI\AIBundle\Profiler\TraceablePlatform; |
29 | 29 | use Symfony\AI\AIBundle\Profiler\TraceableToolbox; |
30 | | -use Symfony\AI\Platform\Bridge\Anthropic\Claude; |
31 | 30 | use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory as AnthropicPlatformFactory; |
32 | 31 | use Symfony\AI\Platform\Bridge\Azure\OpenAI\PlatformFactory as AzureOpenAIPlatformFactory; |
33 | | -use Symfony\AI\Platform\Bridge\Google\Gemini; |
34 | 32 | use Symfony\AI\Platform\Bridge\Google\PlatformFactory as GooglePlatformFactory; |
35 | | -use Symfony\AI\Platform\Bridge\Meta\Llama; |
36 | | -use Symfony\AI\Platform\Bridge\Mistral\Mistral; |
37 | 33 | use Symfony\AI\Platform\Bridge\Mistral\PlatformFactory as MistralPlatformFactory; |
38 | | -use Symfony\AI\Platform\Bridge\OpenAI\Embeddings; |
39 | | -use Symfony\AI\Platform\Bridge\OpenAI\GPT; |
40 | 34 | use Symfony\AI\Platform\Bridge\OpenAI\PlatformFactory as OpenAIPlatformFactory; |
41 | 35 | use Symfony\AI\Platform\Bridge\OpenRouter\PlatformFactory as OpenRouterPlatformFactory; |
42 | | -use Symfony\AI\Platform\Bridge\Voyage\Voyage; |
43 | 36 | use Symfony\AI\Platform\Model; |
44 | 37 | use Symfony\AI\Platform\ModelClientInterface; |
45 | 38 | use Symfony\AI\Platform\Platform; |
@@ -261,20 +254,15 @@ private function processPlatformConfig(string $type, array $platform, ContainerB |
261 | 254 | private function processAgentConfig(string $name, array $config, ContainerBuilder $container): void |
262 | 255 | { |
263 | 256 | // MODEL |
264 | | - ['name' => $modelName, 'version' => $version, 'options' => $options] = $config['model']; |
265 | | - |
266 | | - $modelClass = match (strtolower((string) $modelName)) { |
267 | | - 'gpt' => GPT::class, |
268 | | - 'claude' => Claude::class, |
269 | | - 'llama' => Llama::class, |
270 | | - 'gemini' => Gemini::class, |
271 | | - 'mistral' => Mistral::class, |
272 | | - 'openrouter' => Model::class, |
273 | | - default => throw new \InvalidArgumentException(\sprintf('Model "%s" is not supported.', $modelName)), |
274 | | - }; |
| 257 | + ['class' => $modelClass, 'name' => $modelName, 'options' => $options] = $config['model']; |
| 258 | + |
| 259 | + if (!is_a($modelClass, Model::class, true)) { |
| 260 | + throw new \InvalidArgumentException(\sprintf('"%s" class is not extending Symfony\AI\Platform\Model.', $modelClass)); |
| 261 | + } |
| 262 | + |
275 | 263 | $modelDefinition = new Definition($modelClass); |
276 | | - if (null !== $version) { |
277 | | - $modelDefinition->setArgument('$name', $version); |
| 264 | + if (null !== $modelName) { |
| 265 | + $modelDefinition->setArgument('$name', $modelName); |
278 | 266 | } |
279 | 267 | if ([] !== $options) { |
280 | 268 | $modelDefinition->setArgument('$options', $options); |
@@ -473,20 +461,20 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde |
473 | 461 | */ |
474 | 462 | private function processIndexerConfig(int|string $name, array $config, ContainerBuilder $container): void |
475 | 463 | { |
476 | | - ['name' => $modelName, 'version' => $version, 'options' => $options] = $config['model']; |
477 | | - |
478 | | - $modelClass = match (strtolower((string) $modelName)) { |
479 | | - 'embeddings' => Embeddings::class, |
480 | | - 'voyage' => Voyage::class, |
481 | | - default => throw new \InvalidArgumentException(\sprintf('Model "%s" is not supported.', $modelName)), |
482 | | - }; |
483 | | - $modelDefinition = (new Definition($modelClass)); |
484 | | - if (null !== $version) { |
485 | | - $modelDefinition->setArgument('$name', $version); |
| 464 | + ['class' => $modelClass, 'name' => $modelName, 'options' => $options] = $config['model']; |
| 465 | + |
| 466 | + if (!is_a($modelClass, Model::class, true)) { |
| 467 | + throw new \InvalidArgumentException(\sprintf('"%s" class is not extending Symfony\AI\Platform\Model.', $modelClass)); |
| 468 | + } |
| 469 | + |
| 470 | + $modelDefinition = (new Definition((string) $modelClass)); |
| 471 | + if (null !== $modelName) { |
| 472 | + $modelDefinition->setArgument('$name', $modelName); |
486 | 473 | } |
487 | 474 | if ([] !== $options) { |
488 | 475 | $modelDefinition->setArgument('$options', $options); |
489 | 476 | } |
| 477 | + |
490 | 478 | $modelDefinition->addTag('symfony_ai.model.embeddings_model'); |
491 | 479 | $container->setDefinition('symfony_ai.indexer.'.$name.'.model', $modelDefinition); |
492 | 480 |
|
|
0 commit comments