Skip to content

Commit 01fddff

Browse files
committed
chore: lib v0.24 compatibility (#101)
1 parent c9beb52 commit 01fddff

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/DependencyInjection/AIExtension.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
use Symfony\AI\Store\Bridge\ChromaDB\Store as ChromaDBStore;
5050
use Symfony\AI\Store\Bridge\MongoDB\Store as MongoDBStore;
5151
use Symfony\AI\Store\Bridge\Pinecone\Store as PineconeStore;
52+
use Symfony\AI\Store\Document\Vectorizer;
5253
use Symfony\AI\Store\Indexer;
5354
use Symfony\AI\Store\StoreInterface;
5455
use Symfony\AI\Store\VectorStoreInterface;
@@ -484,9 +485,14 @@ private function processIndexerConfig(int|string $name, array $config, Container
484485
$modelDefinition->addTag('symfony_ai.model.embeddings_model');
485486
$container->setDefinition('symfony_ai.indexer.'.$name.'.model', $modelDefinition);
486487

487-
$definition = new Definition(Indexer::class, [
488-
'$model' => new Reference('symfony_ai.indexer.'.$name.'.model'),
488+
$vectorizerDefinition = new Definition(Vectorizer::class, [
489489
'$platform' => new Reference($config['platform']),
490+
'$model' => new Reference('symfony_ai.indexer.'.$name.'.model'),
491+
]);
492+
$container->setDefinition('symfony_ai.indexer.'.$name.'.vectorizer', $vectorizerDefinition);
493+
494+
$definition = new Definition(Indexer::class, [
495+
'$vectorizer' => new Reference('symfony_ai.indexer.'.$name.'.vectorizer'),
490496
'$store' => new Reference($config['store']),
491497
]);
492498

src/Profiler/DataCollector.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\AI\AIBundle\Profiler;
1313

1414
use Symfony\AI\Agent\Toolbox\ToolboxInterface;
15+
use Symfony\AI\Platform\Model;
1516
use Symfony\AI\Platform\Tool\Tool;
1617
use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
1718
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
@@ -55,7 +56,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
5556
{
5657
$this->data = [
5758
'tools' => $this->defaultToolBox->getTools(),
58-
'platform_calls' => array_merge(...array_map(fn (TraceablePlatform $platform) => $platform->calls, $this->platforms)),
59+
'platform_calls' => array_merge(...array_map($this->awaitCallResults(...), $this->platforms)),
5960
'tool_calls' => array_merge(...array_map(fn (TraceableToolbox $toolbox) => $toolbox->calls, $this->toolboxes)),
6061
];
6162
}
@@ -88,4 +89,23 @@ public function getToolCalls(): array
8889
{
8990
return $this->data['tool_calls'] ?? [];
9091
}
92+
93+
/**
94+
* @return array{
95+
* model: Model,
96+
* input: array<mixed>|string|object,
97+
* options: array<string, mixed>,
98+
* response: string|iterable<mixed>|object|null
99+
* }[]
100+
*/
101+
private function awaitCallResults(TraceablePlatform $platform): array
102+
{
103+
$calls = $platform->calls;
104+
foreach ($calls as $key => $call) {
105+
$call['response'] = $call['response']->await()->getContent();
106+
$calls[$key] = $call;
107+
}
108+
109+
return $calls;
110+
}
91111
}

0 commit comments

Comments
 (0)