Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/ai-bundle/src/DependencyInjection/AIExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, but I am currently on a phone 📱, we don't use named argument in Symfony, but index based assignments.

cc @Nyholm

Ofc in an extra PR

'$store' => new Reference($config['store']),
]);

Expand Down
22 changes: 21 additions & 1 deletion src/ai-bundle/src/Profiler/DataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)),
];
}
Expand Down Expand Up @@ -88,4 +89,23 @@ public function getToolCalls(): array
{
return $this->data['tool_calls'] ?? [];
}

/**
* @return array{
* model: Model,
* input: array<mixed>|string|object,
* options: array<string, mixed>,
* response: string|iterable<mixed>|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;
}
}