Skip to content

Commit 992e0d6

Browse files
webui: add developer setting to toggle the chat model selector
1 parent d1311aa commit 992e0d6

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormActions.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import ChatFormActionFileAttachments from './ChatFormActionFileAttachments.svelte';
55
import ChatFormActionRecord from './ChatFormActionRecord.svelte';
66
import ChatFormModelSelector from './ChatFormModelSelector.svelte';
7+
import { config } from '$lib/stores/settings.svelte';
78
import type { FileTypeCategory } from '$lib/enums/files';
89
910
interface Props {
@@ -27,12 +28,15 @@
2728
onMicClick,
2829
onStop
2930
}: Props = $props();
31+
let currentConfig = $derived(config());
3032
</script>
3133

3234
<div class="flex w-full items-center gap-2 {className}">
3335
<ChatFormActionFileAttachments class="mr-auto" {disabled} {onFileUpload} />
3436

35-
<ChatFormModelSelector class="shrink-0" />
37+
{#if currentConfig.modelSelectorEnabled}
38+
<ChatFormModelSelector class="shrink-0" />
39+
{/if}
3640

3741
{#if isLoading}
3842
<Button

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
@@ -216,6 +216,11 @@
216216
title: 'Developer',
217217
icon: Code,
218218
fields: [
219+
{
220+
key: 'modelSelectorEnabled',
221+
label: 'Enable model selector',
222+
type: 'checkbox'
223+
},
219224
{
220225
key: 'disableReasoningFormat',
221226
label: 'Show raw LLM output',

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
1313
pdfAsImage: false,
1414
showModelInfo: false,
1515
renderUserContentAsMarkdown: false,
16+
modelSelectorEnabled: false,
1617
// make sure these default values are in sync with `common.h`
1718
samplers: 'top_k;typ_p;top_p;min_p;temperature',
1819
temperature: 0.8,
@@ -86,6 +87,8 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
8687
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',
8788
showModelInfo: 'Display the model name used to generate each message below the message content.',
8889
renderUserContentAsMarkdown: 'Render user messages using markdown formatting in the chat.',
90+
modelSelectorEnabled:
91+
'Enable the model selector in the chat input to choose the inference model. Sends the associated model field in API requests.',
8992
pyInterpreterEnabled:
9093
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.'
9194
};

tools/server/webui/src/lib/services/chat.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ export class ChatService {
121121
stream
122122
};
123123

124-
const activeModel = selectedModelName();
125-
if (activeModel) {
124+
const modelSelectorEnabled = Boolean(currentConfig.modelSelectorEnabled);
125+
const activeModel = modelSelectorEnabled ? selectedModelName() : null;
126+
if (modelSelectorEnabled && activeModel) {
126127
requestBody.model = activeModel;
127128
}
128129

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class SettingsStore {
8080
if (!browser) return;
8181

8282
try {
83-
const savedVal = JSON.parse(localStorage.getItem('config') || '{}');
83+
const storedConfigRaw = localStorage.getItem('config');
84+
const savedVal = JSON.parse(storedConfigRaw || '{}');
8485

8586
// Merge with defaults to prevent breaking changes
8687
this.config = {

0 commit comments

Comments
 (0)