|
22 | 22 | use Symfony\AI\Store\Document\Vectorizer; |
23 | 23 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
24 | 24 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 25 | +use Symfony\Component\DependencyInjection\ContainerInterface; |
25 | 26 | use Symfony\Component\DependencyInjection\Definition; |
26 | 27 | use Symfony\Component\DependencyInjection\Reference; |
27 | 28 |
|
@@ -622,6 +623,41 @@ public function testVectorizerConfiguration() |
622 | 623 | $this->assertTrue($modelDefinition->hasTag('ai.model.embeddings_model')); |
623 | 624 | } |
624 | 625 |
|
| 626 | + public function testVectorizerWithLoggerInjection() |
| 627 | + { |
| 628 | + $container = $this->buildContainer([ |
| 629 | + 'ai' => [ |
| 630 | + 'vectorizer' => [ |
| 631 | + 'my_vectorizer' => [ |
| 632 | + 'platform' => 'my_platform_service_id', |
| 633 | + 'model' => [ |
| 634 | + 'class' => 'Symfony\AI\Platform\Bridge\OpenAi\Embeddings', |
| 635 | + 'name' => 'text-embedding-3-small', |
| 636 | + ], |
| 637 | + ], |
| 638 | + ], |
| 639 | + ], |
| 640 | + ]); |
| 641 | + |
| 642 | + $vectorizerDefinition = $container->getDefinition('ai.vectorizer.my_vectorizer'); |
| 643 | + $arguments = $vectorizerDefinition->getArguments(); |
| 644 | + |
| 645 | + $this->assertCount(3, $arguments, 'Vectorizer should have 3 arguments: platform, model, and logger'); |
| 646 | + |
| 647 | + // First argument should be platform reference |
| 648 | + $this->assertInstanceOf(Reference::class, $arguments[0]); |
| 649 | + $this->assertSame('my_platform_service_id', (string) $arguments[0]); |
| 650 | + |
| 651 | + // Second argument should be model reference |
| 652 | + $this->assertInstanceOf(Reference::class, $arguments[1]); |
| 653 | + $this->assertSame('ai.vectorizer.my_vectorizer.model', (string) $arguments[1]); |
| 654 | + |
| 655 | + // Third argument should be logger reference with IGNORE_ON_INVALID_REFERENCE |
| 656 | + $this->assertInstanceOf(Reference::class, $arguments[2]); |
| 657 | + $this->assertSame('logger', (string) $arguments[2]); |
| 658 | + $this->assertSame(ContainerInterface::IGNORE_ON_INVALID_REFERENCE, $arguments[2]->getInvalidBehavior()); |
| 659 | + } |
| 660 | + |
625 | 661 | public function testIndexerWithConfiguredVectorizer() |
626 | 662 | { |
627 | 663 | $container = $this->buildContainer([ |
|
0 commit comments