|
12 | 12 | namespace Symfony\AI\AIBundle\Profiler;
|
13 | 13 |
|
14 | 14 | use Symfony\AI\Agent\Toolbox\ToolboxInterface;
|
| 15 | +use Symfony\AI\Platform\Model; |
15 | 16 | use Symfony\AI\Platform\Tool\Tool;
|
16 | 17 | use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
|
17 | 18 | use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
|
@@ -55,7 +56,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
|
55 | 56 | {
|
56 | 57 | $this->data = [
|
57 | 58 | '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)), |
59 | 60 | 'tool_calls' => array_merge(...array_map(fn (TraceableToolbox $toolbox) => $toolbox->calls, $this->toolboxes)),
|
60 | 61 | ];
|
61 | 62 | }
|
@@ -88,4 +89,23 @@ public function getToolCalls(): array
|
88 | 89 | {
|
89 | 90 | return $this->data['tool_calls'] ?? [];
|
90 | 91 | }
|
| 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 | + } |
91 | 111 | }
|
0 commit comments