diff --git a/src/ai-bundle/src/DependencyInjection/AIExtension.php b/src/ai-bundle/src/DependencyInjection/AIExtension.php index 3ebd2b9b45..ea42504fd1 100644 --- a/src/ai-bundle/src/DependencyInjection/AIExtension.php +++ b/src/ai-bundle/src/DependencyInjection/AIExtension.php @@ -49,6 +49,7 @@ use Symfony\AI\Store\Bridge\ChromaDB\Store as ChromaDBStore; use Symfony\AI\Store\Bridge\MongoDB\Store as MongoDBStore; use Symfony\AI\Store\Bridge\Pinecone\Store as PineconeStore; +use Symfony\AI\Store\Document\Vectorizer; use Symfony\AI\Store\Indexer; use Symfony\AI\Store\StoreInterface; use Symfony\AI\Store\VectorStoreInterface; @@ -484,9 +485,14 @@ private function processIndexerConfig(int|string $name, array $config, Container $modelDefinition->addTag('symfony_ai.model.embeddings_model'); $container->setDefinition('symfony_ai.indexer.'.$name.'.model', $modelDefinition); - $definition = new Definition(Indexer::class, [ - '$model' => new Reference('symfony_ai.indexer.'.$name.'.model'), + $vectorizerDefinition = new Definition(Vectorizer::class, [ '$platform' => new Reference($config['platform']), + '$model' => new Reference('symfony_ai.indexer.'.$name.'.model'), + ]); + $container->setDefinition('symfony_ai.indexer.'.$name.'.vectorizer', $vectorizerDefinition); + + $definition = new Definition(Indexer::class, [ + '$vectorizer' => new Reference('symfony_ai.indexer.'.$name.'.vectorizer'), '$store' => new Reference($config['store']), ]); diff --git a/src/ai-bundle/src/Profiler/DataCollector.php b/src/ai-bundle/src/Profiler/DataCollector.php index 3cef5bf4f1..c0a2cd25bd 100644 --- a/src/ai-bundle/src/Profiler/DataCollector.php +++ b/src/ai-bundle/src/Profiler/DataCollector.php @@ -12,6 +12,7 @@ namespace Symfony\AI\AIBundle\Profiler; use Symfony\AI\Agent\Toolbox\ToolboxInterface; +use Symfony\AI\Platform\Model; use Symfony\AI\Platform\Tool\Tool; use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; @@ -55,7 +56,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep { $this->data = [ 'tools' => $this->defaultToolBox->getTools(), - 'platform_calls' => array_merge(...array_map(fn (TraceablePlatform $platform) => $platform->calls, $this->platforms)), + 'platform_calls' => array_merge(...array_map($this->awaitCallResults(...), $this->platforms)), 'tool_calls' => array_merge(...array_map(fn (TraceableToolbox $toolbox) => $toolbox->calls, $this->toolboxes)), ]; } @@ -88,4 +89,23 @@ public function getToolCalls(): array { return $this->data['tool_calls'] ?? []; } + + /** + * @return array{ + * model: Model, + * input: array|string|object, + * options: array, + * response: string|iterable|object|null + * }[] + */ + private function awaitCallResults(TraceablePlatform $platform): array + { + $calls = $platform->calls; + foreach ($calls as $key => $call) { + $call['response'] = $call['response']->await()->getContent(); + $calls[$key] = $call; + } + + return $calls; + } }