Skip to content

Commit b4c5cc7

Browse files
naming, improving display
1 parent cefff42 commit b4c5cc7

File tree

3 files changed

+56
-43
lines changed

3 files changed

+56
-43
lines changed

src/ai-bundle/src/Profiler/DataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function lateCollect(): void
6969
];
7070
}
7171

72-
public function collectChatCall(string $method, float $duration, mixed $input, mixed $result, ?\Throwable $error): void
72+
public function collectAgentCall(string $method, float $duration, mixed $input, mixed $result, ?\Throwable $error): void
7373
{
7474
$this->collectedChatCalls[] = [
7575
'method' => $method,
@@ -112,7 +112,7 @@ public function getToolCalls(): array
112112
/**
113113
* @return list<array{method: string, duration: float, input: mixed, result: mixed, error: ?\Throwable}>
114114
*/
115-
public function getChatCalls(): array
115+
public function getAgentCalls(): array
116116
{
117117
if (!isset($this->data['chat_calls'])) {
118118
return [];

src/ai-bundle/src/Profiler/TraceableAgent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function call(MessageBag $messages, array $options = []): ResultInterface
3636
$error = $e;
3737
throw $e;
3838
} finally {
39-
$this->collector->collectChatCall(
39+
$this->collector->collectAgentCall(
4040
'call',
4141
microtime(true) - $startTime,
4242
$messages,

src/ai-bundle/templates/data_collector.html.twig

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

3+
{% block head %}
4+
{{ parent() }}
5+
<style>
6+
.profiler-content table.table pre {
7+
white-space: pre-wrap;
8+
word-wrap: break-word;
9+
overflow-wrap: break-word;
10+
}
11+
</style>
12+
{% endblock %}
13+
314
{% block toolbar %}
415
{% if collector.platformCalls|length > 0 %}
516
{% set icon %}
@@ -13,8 +24,8 @@
1324
{% set text %}
1425
<div class="sf-toolbar-info-piece">
1526
<div class="sf-toolbar-info-piece">
16-
<b class="label">Chat Calls</b>
17-
<span class="sf-toolbar-status">{{ collector.chatCalls|length }}</span>
27+
<b class="label">Agent Calls</b>
28+
<span class="sf-toolbar-status">{{ collector.agentCalls|length }}</span>
1829
</div>
1930
<div class="sf-toolbar-info-piece">
2031
<b class="label">Configured Platforms</b>
@@ -62,8 +73,8 @@
6273
{% block panel %}
6374
<h2>Symfony AI</h2>
6475

65-
<h3>Chat Calls</h3>
66-
{% if collector.chatCalls|length %}
76+
<h3>Agent Calls</h3>
77+
{% if collector.agentCalls|length %}
6778
<table class="table">
6879
<thead>
6980
<tr>
@@ -75,15 +86,19 @@
7586
</tr>
7687
</thead>
7788
<tbody>
78-
{% for call in collector.chatCalls %}
89+
{% for call in collector.agentCalls %}
7990
<tr>
8091
<td><code>{{ call.method }}</code></td>
8192
<td class="text-nowrap">{{ (call.duration * 1000)|round(2) }} ms</td>
82-
<td>{{ dump(call.input) }}</td>
83-
<td>{{ dump(call.result) }}</td>
93+
<td>
94+
<div style="max-width: 400px; overflow-x: auto;"><pre>{{ dump(call.input) }}</pre></div>
95+
</td>
96+
<td>
97+
<div style="max-width: 400px; overflow-x: auto;"><pre>{{ dump(call.result) }}</pre></div>
98+
</td>
8499
<td>
85100
{% if call.error %}
86-
{{ dump(call.error) }}
101+
<pre>{{ dump(call.error) }}</pre>
87102
{% else %}
88103
<span class="text-muted">None</span>
89104
{% endif %}
@@ -94,19 +109,16 @@
94109
</table>
95110
{% else %}
96111
<div class="empty">
97-
<p>No chat calls were made.</p>
112+
<p>No agent calls were made.</p>
98113
</div>
99114
{% endif %}
100115

101116
<section class="metrics">
102117
<div class="metric-group">
103118
<div class="metric">
104-
<span class="value">{{ collector.chatCalls|length }}</span>
105-
<span class="label">Chat Calls</span>
119+
<span class="value">{{ collector.agentCalls|length }}</span>
120+
<span class="label">Agent Calls</span>
106121
</div>
107-
</div>
108-
<div class="metric-divider"></div>
109-
<div class="metric-group">
110122
<div class="metric">
111123
<span class="value">1</span>
112124
<span class="label">Platforms</span>
@@ -128,6 +140,7 @@
128140
</div>
129141
</div>
130142
</section>
143+
131144
<h3>Platform Calls</h3>
132145
{% if collector.platformCalls|length %}
133146
<div class="sf-tabs">
@@ -137,9 +150,9 @@
137150
{% for call in collector.platformCalls %}
138151
<table class="table">
139152
<thead>
140-
<tr>
141-
<th colspan="2">Call {{ loop.index }}</th>
142-
</tr>
153+
<tr>
154+
<th colspan="2">Call {{ loop.index }}</th>
155+
</tr>
143156
</thead>
144157
<tbody>
145158
<tr>
@@ -174,7 +187,7 @@
174187
{% endfor %}
175188
</ol>
176189
{% else %}
177-
{{ dump(call.input) }}
190+
<pre>{{ dump(call.input) }}</pre>
178191
{% endif %}
179192
</td>
180193
</tr>
@@ -192,7 +205,7 @@
192205
</ul>
193206
</li>
194207
{% else %}
195-
<li>{{ key }}: {{ dump(value) }}</li>
208+
<li>{{ key }}: <pre>{{ dump(value) }}</pre></li>
196209
{% endif %}
197210
{% endfor %}
198211
</ul>
@@ -230,12 +243,12 @@
230243
{% if collector.tools|length %}
231244
<table class="table">
232245
<thead>
233-
<tr>
234-
<th>Name</th>
235-
<th>Description</th>
236-
<th>Class & Method</th>
237-
<th>Parameters</th>
238-
</tr>
246+
<tr>
247+
<th>Name</th>
248+
<th>Description</th>
249+
<th>Class & Method</th>
250+
<th>Parameters</th>
251+
</tr>
239252
</thead>
240253
<tbody>
241254
{% for tool in collector.tools %}
@@ -272,23 +285,23 @@
272285
{% for call in collector.toolCalls %}
273286
<table class="table">
274287
<thead>
275-
<tr>
276-
<th colspan="2">{{ call.call.name }}</th>
277-
</tr>
288+
<tr>
289+
<th colspan="2">{{ call.call.name }}</th>
290+
</tr>
278291
</thead>
279292
<tbody>
280-
<tr>
281-
<th>ID</th>
282-
<td>{{ call.call.id }}</td>
283-
</tr>
284-
<tr>
285-
<th>Arguments</th>
286-
<td>{{ dump(call.call.arguments) }}</td>
287-
</tr>
288-
<tr>
289-
<th>Result</th>
290-
<td>{{ dump(call.result) }}</td>
291-
</tr>
293+
<tr>
294+
<th>ID</th>
295+
<td>{{ call.call.id }}</td>
296+
</tr>
297+
<tr>
298+
<th>Arguments</th>
299+
<td><pre>{{ dump(call.call.arguments) }}</pre></td>
300+
</tr>
301+
<tr>
302+
<th>Result</th>
303+
<td><pre>{{ dump(call.result) }}</pre></td>
304+
</tr>
292305
</tbody>
293306
</table>
294307
{% endfor %}

0 commit comments

Comments
 (0)