Skip to content

Commit 4f15759

Browse files
authored
Add optional setting for showing "Model used:" information (ggml-org#16337)
* feat: Add a setting to include model name used to generate the message * feat: UI improvements * feat: Save model info along with the database message entry creation * chore: Build webui static output
1 parent 132d673 commit 4f15759

File tree

7 files changed

+48
-8
lines changed

7 files changed

+48
-8
lines changed

tools/server/public/index.html.gz

501 Bytes
Binary file not shown.

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
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, X } from '@lucide/svelte';
6+
import { Check, Copy, Package, X } from '@lucide/svelte';
77
import { Button } from '$lib/components/ui/button';
88
import { Checkbox } from '$lib/components/ui/checkbox';
99
import { INPUT_CLASSES } from '$lib/constants/input-classes';
1010
import ChatMessageActions from './ChatMessageActions.svelte';
1111
import Label from '$lib/components/ui/label/label.svelte';
12+
import { config } from '$lib/stores/settings.svelte';
13+
import { copyToClipboard } from '$lib/utils/copy';
1214
1315
interface Props {
1416
class?: string;
@@ -136,6 +138,23 @@
136138
</div>
137139
{/if}
138140

141+
{#if config().showModelInfo && message.model}
142+
<span class="mt-6 mb-4 inline-flex items-center gap-1 text-xs text-muted-foreground">
143+
<Package class="h-3.5 w-3.5" />
144+
145+
<span>Model used:</span>
146+
147+
<button
148+
class="inline-flex cursor-pointer items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75"
149+
onclick={() => copyToClipboard(message.model)}
150+
>
151+
{message.model}
152+
153+
<Copy class="ml-1 h-3 w-3 " />
154+
</button>
155+
</span>
156+
{/if}
157+
139158
{#if message.timestamp && !isEditing}
140159
<ChatMessageActions
141160
role="assistant"

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
@@ -75,6 +75,11 @@
7575
key: 'pdfAsImage',
7676
label: 'Parse PDF as image',
7777
type: 'checkbox'
78+
},
79+
{
80+
key: 'showModelInfo',
81+
label: 'Show model information',
82+
type: 'checkbox'
7883
}
7984
]
8085
},

tools/server/webui/src/lib/components/app/misc/ActionButton.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{size}
3535
{disabled}
3636
{onclick}
37-
class="h-6 w-6 p-0 {className}"
37+
class="h-6 w-6 p-0 {className} flex"
3838
aria-label={ariaLabel || tooltip}
3939
>
4040
{@const IconComponent = icon}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
1010
askForTitleConfirmation: false,
1111
pasteLongTextToFileLen: 2500,
1212
pdfAsImage: false,
13+
showModelInfo: false,
1314
// make sure these default values are in sync with `common.h`
1415
samplers: 'top_k;typ_p;top_p;min_p;temperature',
1516
temperature: 0.8,
@@ -79,6 +80,7 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
7980
askForTitleConfirmation:
8081
'Ask for confirmation before automatically changing conversation title when editing the first message.',
8182
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',
83+
showModelInfo: 'Display the model name used to generate each message below the message content.',
8284
pyInterpreterEnabled:
8385
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.'
8486
};

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ class ChatStore {
353353

354354
await DatabaseStore.updateCurrentNode(this.activeConversation!.id, assistantMessage.id);
355355
this.activeConversation!.currNode = assistantMessage.id;
356-
357356
await this.refreshActiveMessages();
358357

359358
if (onComplete) {
@@ -479,6 +478,9 @@ class ChatStore {
479478
private async createAssistantMessage(parentId?: string): Promise<DatabaseMessage | null> {
480479
if (!this.activeConversation) return null;
481480

481+
// Capture the current model name when creating the assistant message
482+
const currentModelName = serverStore.modelName;
483+
482484
return await DatabaseStore.createMessageBranch(
483485
{
484486
convId: this.activeConversation.id,
@@ -487,7 +489,8 @@ class ChatStore {
487489
content: '',
488490
timestamp: Date.now(),
489491
thinking: '',
490-
children: []
492+
children: [],
493+
model: currentModelName || undefined
491494
},
492495
parentId || null
493496
);
@@ -1138,7 +1141,8 @@ class ChatStore {
11381141
role: messageToEdit.role,
11391142
content: newContent,
11401143
thinking: messageToEdit.thinking || '',
1141-
children: []
1144+
children: [],
1145+
model: messageToEdit.model // Preserve original model info when branching
11421146
},
11431147
messageToEdit.parent!
11441148
);
@@ -1213,7 +1217,8 @@ class ChatStore {
12131217
content: newContent,
12141218
thinking: messageToEdit.thinking || '',
12151219
children: [],
1216-
extra: messageToEdit.extra ? JSON.parse(JSON.stringify(messageToEdit.extra)) : undefined
1220+
extra: messageToEdit.extra ? JSON.parse(JSON.stringify(messageToEdit.extra)) : undefined,
1221+
model: messageToEdit.model // Preserve original model info when branching
12171222
},
12181223
parentId
12191224
);
@@ -1274,6 +1279,9 @@ class ChatStore {
12741279
this.isLoading = true;
12751280
this.currentResponse = '';
12761281

1282+
// Capture the current model name when creating the assistant message
1283+
const currentModelName = serverStore.modelName;
1284+
12771285
const newAssistantMessage = await DatabaseStore.createMessageBranch(
12781286
{
12791287
convId: this.activeConversation.id,
@@ -1282,7 +1290,8 @@ class ChatStore {
12821290
role: 'assistant',
12831291
content: '',
12841292
thinking: '',
1285-
children: []
1293+
children: [],
1294+
model: currentModelName || undefined
12861295
},
12871296
parentMessage.id
12881297
);
@@ -1329,6 +1338,9 @@ class ChatStore {
13291338
false
13301339
) as DatabaseMessage[];
13311340

1341+
// Capture the current model name when creating the assistant message
1342+
const currentModelName = serverStore.modelName;
1343+
13321344
// Create new assistant message branch
13331345
const assistantMessage = await DatabaseStore.createMessageBranch(
13341346
{
@@ -1338,7 +1350,8 @@ class ChatStore {
13381350
role: 'assistant',
13391351
content: '',
13401352
thinking: '',
1341-
children: []
1353+
children: [],
1354+
model: currentModelName || undefined
13421355
},
13431356
userMessageId
13441357
);

tools/server/webui/src/lib/types/database.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ export interface DatabaseMessage {
5252
children: string[];
5353
extra?: DatabaseMessageExtra[];
5454
timings?: ChatMessageTimings;
55+
model?: string;
5556
}

0 commit comments

Comments
 (0)