Skip to content

Commit d8b860a

Browse files
authored
Add a setting to display message generation statistics (ggml-org#16901)
* feat: Add setting to display message generation statistics * chore: build static webui output
1 parent 1ae7488 commit d8b860a

File tree

4 files changed

+67
-14
lines changed

4 files changed

+67
-14
lines changed

tools/server/public/index.html.gz

1.75 KB
Binary file not shown.

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessageAssistant.svelte

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
import { useProcessingState } from '$lib/hooks/use-processing-state.svelte';
44
import { isLoading } from '$lib/stores/chat.svelte';
55
import { fade } from 'svelte/transition';
6-
import { Check, Copy, Package, X } from '@lucide/svelte';
6+
import {
7+
Check,
8+
Copy,
9+
Package,
10+
X,
11+
Gauge,
12+
Clock,
13+
WholeWord,
14+
ChartNoAxesColumn
15+
} from '@lucide/svelte';
716
import { Button } from '$lib/components/ui/button';
817
import { Checkbox } from '$lib/components/ui/checkbox';
918
import { INPUT_CLASSES } from '$lib/constants/input-classes';
@@ -160,22 +169,58 @@
160169
</div>
161170
{/if}
162171

163-
{#if displayedModel()}
164-
<span class="mt-6 mb-4 inline-flex items-center gap-1 text-xs text-muted-foreground">
165-
<Package class="h-3.5 w-3.5" />
172+
<div class="info my-6 grid gap-4">
173+
{#if displayedModel()}
174+
<span class="inline-flex items-center gap-2 text-xs text-muted-foreground">
175+
<span class="inline-flex items-center gap-1">
176+
<Package class="h-3.5 w-3.5" />
166177

167-
<span>Model used:</span>
178+
<span>Model used:</span>
179+
</span>
168180

169-
<button
170-
class="inline-flex cursor-pointer items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75"
171-
onclick={handleCopyModel}
172-
>
173-
{displayedModel()}
181+
<button
182+
class="inline-flex cursor-pointer items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75"
183+
onclick={handleCopyModel}
184+
>
185+
{displayedModel()}
174186

175-
<Copy class="ml-1 h-3 w-3 " />
176-
</button>
177-
</span>
178-
{/if}
187+
<Copy class="ml-1 h-3 w-3 " />
188+
</button>
189+
</span>
190+
{/if}
191+
192+
{#if currentConfig.showMessageStats && message.timings && message.timings.predicted_n && message.timings.predicted_ms}
193+
{@const tokensPerSecond = (message.timings.predicted_n / message.timings.predicted_ms) * 1000}
194+
<span class="inline-flex items-center gap-2 text-xs text-muted-foreground">
195+
<span class="inline-flex items-center gap-1">
196+
<ChartNoAxesColumn class="h-3.5 w-3.5" />
197+
198+
<span>Statistics:</span>
199+
</span>
200+
201+
<div class="inline-flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
202+
<span
203+
class="inline-flex items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75"
204+
>
205+
<Gauge class="h-3 w-3" />
206+
{tokensPerSecond.toFixed(2)} tokens/s
207+
</span>
208+
<span
209+
class="inline-flex items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75"
210+
>
211+
<WholeWord class="h-3 w-3" />
212+
{message.timings.predicted_n} tokens
213+
</span>
214+
<span
215+
class="inline-flex items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75"
216+
>
217+
<Clock class="h-3 w-3" />
218+
{(message.timings.predicted_ms / 1000).toFixed(2)}s
219+
</span>
220+
</div>
221+
</span>
222+
{/if}
223+
</div>
179224

180225
{#if message.timestamp && !isEditing}
181226
<ChatMessageActions

tools/server/webui/src/lib/components/app/chat/ChatSettings/ChatSettingsDialog.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
{ value: 'dark', label: 'Dark', icon: Moon }
5353
]
5454
},
55+
{
56+
key: 'showMessageStats',
57+
label: 'Show message generation statistics',
58+
type: 'checkbox'
59+
},
5560
{
5661
key: 'showTokensPerSecond',
5762
label: 'Show tokens per second',

tools/server/webui/src/lib/constants/settings-config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
88
showThoughtInProgress: false,
99
disableReasoningFormat: false,
1010
keepStatsVisible: false,
11+
showMessageStats: true,
1112
askForTitleConfirmation: false,
1213
pasteLongTextToFileLen: 2500,
1314
pdfAsImage: false,
@@ -82,6 +83,8 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
8283
disableReasoningFormat:
8384
'Show raw LLM output without backend parsing and frontend Markdown rendering to inspect streaming across different models.',
8485
keepStatsVisible: 'Keep processing statistics visible after generation finishes.',
86+
showMessageStats:
87+
'Display generation statistics (tokens/second, token count, duration) below each assistant message.',
8588
askForTitleConfirmation:
8689
'Ask for confirmation before automatically changing conversation title when editing the first message.',
8790
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',

0 commit comments

Comments
 (0)