1313
1414use Symfony \AI \Agent \Toolbox \ToolResult ;
1515use Symfony \AI \Platform \Metadata \Metadata ;
16- use Symfony \AI \Agent \Toolbox \ToolboxInterface ;
1716use Symfony \AI \Platform \Tool \Tool ;
1817use Symfony \Bundle \FrameworkBundle \DataCollector \AbstractDataCollector ;
1918use Symfony \Component \HttpFoundation \Request ;
2625 * @phpstan-import-type PlatformCallData from TraceablePlatform
2726 * @phpstan-import-type ToolCallData from TraceableToolbox
2827 * @phpstan-import-type MessageStoreData from TraceableMessageStore
28+ * @phpstan-import-type ChatData from TraceableChat
2929 */
3030final class DataCollector extends AbstractDataCollector implements LateDataCollectorInterface
3131{
@@ -50,10 +50,10 @@ final class DataCollector extends AbstractDataCollector implements LateDataColle
5050 private readonly array $ chats ;
5151
5252 /**
53- * @param TraceablePlatform[] $platforms
54- * @param TraceableToolbox[] $toolboxes
53+ * @param TraceablePlatform[] $platforms
54+ * @param TraceableToolbox[] $toolboxes
5555 * @param TraceableMessageStore[] $messageStores
56- * @param TraceableChat[] $chats
56+ * @param TraceableChat[] $chats
5757 */
5858 public function __construct (
5959 iterable $ platforms ,
@@ -79,6 +79,7 @@ public function lateCollect(): void
7979 'platform_calls ' => array_merge (...array_map ($ this ->awaitCallResults (...), $ this ->platforms )),
8080 'tool_calls ' => array_merge (...array_map (fn (TraceableToolbox $ toolbox ) => $ toolbox ->calls , $ this ->toolboxes )),
8181 'messages ' => array_merge (...array_map (static fn (TraceableMessageStore $ messageStore ): array => $ messageStore ->calls , $ this ->messageStores )),
82+ 'chats ' => array_merge (...array_map (static fn (TraceableChat $ chat ): array => $ chat ->calls , $ this ->chats )),
8283 ];
8384 }
8485
@@ -112,19 +113,27 @@ public function getToolCalls(): array
112113 }
113114
114115 /**
115- * @return Tool []
116+ * @return MessageStoreData []
116117 */
117- private function getAllTools (): array
118+ public function getMessages (): array
118119 {
119- return array_merge (... array_map ( fn ( TraceableToolbox $ toolbox ) => $ toolbox -> getTools (), $ this ->toolboxes )) ;
120+ return $ this ->data [ ' messages ' ] ?? [] ;
120121 }
121122
122123 /**
123- * @return MessageStoreData []
124+ * @return ChatData []
124125 */
125- public function getMessages (): array
126+ public function getChats (): array
126127 {
127- return $ this ->data ['messages ' ] ?? [];
128+ return $ this ->data ['chats ' ] ?? [];
129+ }
130+
131+ /**
132+ * @return Tool[]
133+ */
134+ private function getAllTools (): array
135+ {
136+ return array_merge (...array_map (fn (TraceableToolbox $ toolbox ) => $ toolbox ->getTools (), $ this ->toolboxes ));
128137 }
129138
130139 /**
0 commit comments