mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-29 08:41:22 +00:00
Add optional setting for showing "Model used:" information (#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
This commit is contained in:
committed by
GitHub
parent
132d673554
commit
4f1575921c
Binary file not shown.
@@ -3,12 +3,14 @@
|
|||||||
import { useProcessingState } from '$lib/hooks/use-processing-state.svelte';
|
import { useProcessingState } from '$lib/hooks/use-processing-state.svelte';
|
||||||
import { isLoading } from '$lib/stores/chat.svelte';
|
import { isLoading } from '$lib/stores/chat.svelte';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { Check, X } from '@lucide/svelte';
|
import { Check, Copy, Package, X } from '@lucide/svelte';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { Checkbox } from '$lib/components/ui/checkbox';
|
import { Checkbox } from '$lib/components/ui/checkbox';
|
||||||
import { INPUT_CLASSES } from '$lib/constants/input-classes';
|
import { INPUT_CLASSES } from '$lib/constants/input-classes';
|
||||||
import ChatMessageActions from './ChatMessageActions.svelte';
|
import ChatMessageActions from './ChatMessageActions.svelte';
|
||||||
import Label from '$lib/components/ui/label/label.svelte';
|
import Label from '$lib/components/ui/label/label.svelte';
|
||||||
|
import { config } from '$lib/stores/settings.svelte';
|
||||||
|
import { copyToClipboard } from '$lib/utils/copy';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
class?: string;
|
class?: string;
|
||||||
@@ -136,6 +138,23 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if config().showModelInfo && message.model}
|
||||||
|
<span class="mt-6 mb-4 inline-flex items-center gap-1 text-xs text-muted-foreground">
|
||||||
|
<Package class="h-3.5 w-3.5" />
|
||||||
|
|
||||||
|
<span>Model used:</span>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="inline-flex cursor-pointer items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75"
|
||||||
|
onclick={() => copyToClipboard(message.model)}
|
||||||
|
>
|
||||||
|
{message.model}
|
||||||
|
|
||||||
|
<Copy class="ml-1 h-3 w-3 " />
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if message.timestamp && !isEditing}
|
{#if message.timestamp && !isEditing}
|
||||||
<ChatMessageActions
|
<ChatMessageActions
|
||||||
role="assistant"
|
role="assistant"
|
||||||
|
|||||||
@@ -75,6 +75,11 @@
|
|||||||
key: 'pdfAsImage',
|
key: 'pdfAsImage',
|
||||||
label: 'Parse PDF as image',
|
label: 'Parse PDF as image',
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'showModelInfo',
|
||||||
|
label: 'Show model information',
|
||||||
|
type: 'checkbox'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
{size}
|
{size}
|
||||||
{disabled}
|
{disabled}
|
||||||
{onclick}
|
{onclick}
|
||||||
class="h-6 w-6 p-0 {className}"
|
class="h-6 w-6 p-0 {className} flex"
|
||||||
aria-label={ariaLabel || tooltip}
|
aria-label={ariaLabel || tooltip}
|
||||||
>
|
>
|
||||||
{@const IconComponent = icon}
|
{@const IconComponent = icon}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
|
|||||||
askForTitleConfirmation: false,
|
askForTitleConfirmation: false,
|
||||||
pasteLongTextToFileLen: 2500,
|
pasteLongTextToFileLen: 2500,
|
||||||
pdfAsImage: false,
|
pdfAsImage: false,
|
||||||
|
showModelInfo: false,
|
||||||
// make sure these default values are in sync with `common.h`
|
// make sure these default values are in sync with `common.h`
|
||||||
samplers: 'top_k;typ_p;top_p;min_p;temperature',
|
samplers: 'top_k;typ_p;top_p;min_p;temperature',
|
||||||
temperature: 0.8,
|
temperature: 0.8,
|
||||||
@@ -79,6 +80,7 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
|
|||||||
askForTitleConfirmation:
|
askForTitleConfirmation:
|
||||||
'Ask for confirmation before automatically changing conversation title when editing the first message.',
|
'Ask for confirmation before automatically changing conversation title when editing the first message.',
|
||||||
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',
|
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',
|
||||||
|
showModelInfo: 'Display the model name used to generate each message below the message content.',
|
||||||
pyInterpreterEnabled:
|
pyInterpreterEnabled:
|
||||||
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.'
|
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -353,7 +353,6 @@ class ChatStore {
|
|||||||
|
|
||||||
await DatabaseStore.updateCurrentNode(this.activeConversation!.id, assistantMessage.id);
|
await DatabaseStore.updateCurrentNode(this.activeConversation!.id, assistantMessage.id);
|
||||||
this.activeConversation!.currNode = assistantMessage.id;
|
this.activeConversation!.currNode = assistantMessage.id;
|
||||||
|
|
||||||
await this.refreshActiveMessages();
|
await this.refreshActiveMessages();
|
||||||
|
|
||||||
if (onComplete) {
|
if (onComplete) {
|
||||||
@@ -479,6 +478,9 @@ class ChatStore {
|
|||||||
private async createAssistantMessage(parentId?: string): Promise<DatabaseMessage | null> {
|
private async createAssistantMessage(parentId?: string): Promise<DatabaseMessage | null> {
|
||||||
if (!this.activeConversation) return null;
|
if (!this.activeConversation) return null;
|
||||||
|
|
||||||
|
// Capture the current model name when creating the assistant message
|
||||||
|
const currentModelName = serverStore.modelName;
|
||||||
|
|
||||||
return await DatabaseStore.createMessageBranch(
|
return await DatabaseStore.createMessageBranch(
|
||||||
{
|
{
|
||||||
convId: this.activeConversation.id,
|
convId: this.activeConversation.id,
|
||||||
@@ -487,7 +489,8 @@ class ChatStore {
|
|||||||
content: '',
|
content: '',
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
thinking: '',
|
thinking: '',
|
||||||
children: []
|
children: [],
|
||||||
|
model: currentModelName || undefined
|
||||||
},
|
},
|
||||||
parentId || null
|
parentId || null
|
||||||
);
|
);
|
||||||
@@ -1138,7 +1141,8 @@ class ChatStore {
|
|||||||
role: messageToEdit.role,
|
role: messageToEdit.role,
|
||||||
content: newContent,
|
content: newContent,
|
||||||
thinking: messageToEdit.thinking || '',
|
thinking: messageToEdit.thinking || '',
|
||||||
children: []
|
children: [],
|
||||||
|
model: messageToEdit.model // Preserve original model info when branching
|
||||||
},
|
},
|
||||||
messageToEdit.parent!
|
messageToEdit.parent!
|
||||||
);
|
);
|
||||||
@@ -1213,7 +1217,8 @@ class ChatStore {
|
|||||||
content: newContent,
|
content: newContent,
|
||||||
thinking: messageToEdit.thinking || '',
|
thinking: messageToEdit.thinking || '',
|
||||||
children: [],
|
children: [],
|
||||||
extra: messageToEdit.extra ? JSON.parse(JSON.stringify(messageToEdit.extra)) : undefined
|
extra: messageToEdit.extra ? JSON.parse(JSON.stringify(messageToEdit.extra)) : undefined,
|
||||||
|
model: messageToEdit.model // Preserve original model info when branching
|
||||||
},
|
},
|
||||||
parentId
|
parentId
|
||||||
);
|
);
|
||||||
@@ -1274,6 +1279,9 @@ class ChatStore {
|
|||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.currentResponse = '';
|
this.currentResponse = '';
|
||||||
|
|
||||||
|
// Capture the current model name when creating the assistant message
|
||||||
|
const currentModelName = serverStore.modelName;
|
||||||
|
|
||||||
const newAssistantMessage = await DatabaseStore.createMessageBranch(
|
const newAssistantMessage = await DatabaseStore.createMessageBranch(
|
||||||
{
|
{
|
||||||
convId: this.activeConversation.id,
|
convId: this.activeConversation.id,
|
||||||
@@ -1282,7 +1290,8 @@ class ChatStore {
|
|||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: '',
|
content: '',
|
||||||
thinking: '',
|
thinking: '',
|
||||||
children: []
|
children: [],
|
||||||
|
model: currentModelName || undefined
|
||||||
},
|
},
|
||||||
parentMessage.id
|
parentMessage.id
|
||||||
);
|
);
|
||||||
@@ -1329,6 +1338,9 @@ class ChatStore {
|
|||||||
false
|
false
|
||||||
) as DatabaseMessage[];
|
) as DatabaseMessage[];
|
||||||
|
|
||||||
|
// Capture the current model name when creating the assistant message
|
||||||
|
const currentModelName = serverStore.modelName;
|
||||||
|
|
||||||
// Create new assistant message branch
|
// Create new assistant message branch
|
||||||
const assistantMessage = await DatabaseStore.createMessageBranch(
|
const assistantMessage = await DatabaseStore.createMessageBranch(
|
||||||
{
|
{
|
||||||
@@ -1338,7 +1350,8 @@ class ChatStore {
|
|||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: '',
|
content: '',
|
||||||
thinking: '',
|
thinking: '',
|
||||||
children: []
|
children: [],
|
||||||
|
model: currentModelName || undefined
|
||||||
},
|
},
|
||||||
userMessageId
|
userMessageId
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -52,4 +52,5 @@ export interface DatabaseMessage {
|
|||||||
children: string[];
|
children: string[];
|
||||||
extra?: DatabaseMessageExtra[];
|
extra?: DatabaseMessageExtra[];
|
||||||
timings?: ChatMessageTimings;
|
timings?: ChatMessageTimings;
|
||||||
|
model?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user