feat: Add auto-mic setting

This commit is contained in:
Aleksander Grygier 2025-11-21 19:51:03 +01:00
parent 6b7c0a5090
commit 69503aa519
3 changed files with 20 additions and 7 deletions

View File

@ -9,6 +9,7 @@
import { FileTypeCategory } from '$lib/enums/files';
import { getFileTypeCategory } from '$lib/utils/file-type';
import { supportsAudio } from '$lib/stores/server.svelte';
import { config } from '$lib/stores/settings.svelte';
import type { ChatUploadedFile } from '$lib/types/chat';
interface Props {
@ -37,11 +38,14 @@
onStop
}: Props = $props();
let currentConfig = $derived(config());
let hasAudioModality = $derived(supportsAudio());
let hasAudioAttachments = $derived(
uploadedFiles.some((file) => getFileTypeCategory(file.type) === FileTypeCategory.AUDIO)
);
let shouldShowRecordButton = $derived(hasAudioModality && !hasText && !hasAudioAttachments);
let shouldShowRecordButton = $derived(
hasAudioModality && !hasText && !hasAudioAttachments && currentConfig.autoMicOnEmpty
);
let shouldShowSubmitButton = $derived(!shouldShowRecordButton || hasAudioAttachments);
</script>

View File

@ -78,12 +78,6 @@
label: 'Show model information',
type: 'checkbox'
},
{
key: 'enableContinueGeneration',
label: 'Enable "Continue" button',
type: 'checkbox',
isExperimental: true
},
{
key: 'pdfAsImage',
label: 'Parse PDF as image',
@ -94,6 +88,18 @@
label: 'Render user content as Markdown',
type: 'checkbox'
},
{
key: 'autoMicOnEmpty',
label: 'Show microphone on empty input',
type: 'checkbox',
isExperimental: true
},
{
key: 'enableContinueGeneration',
label: 'Enable "Continue" button',
type: 'checkbox',
isExperimental: true
},
{
key: 'askForTitleConfirmation',
label: 'Ask for confirmation before changing conversation title',

View File

@ -16,6 +16,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
showModelInfo: false,
renderUserContentAsMarkdown: false,
modelSelectorEnabled: false,
autoMicOnEmpty: false,
// make sure these default values are in sync with `common.h`
samplers: 'top_k;typ_p;top_p;min_p;temperature',
temperature: 0.8,
@ -96,6 +97,8 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
renderUserContentAsMarkdown: 'Render user messages using markdown formatting in the chat.',
modelSelectorEnabled:
'Enable the model selector in the chat input to choose the inference model. Sends the associated model field in API requests.',
autoMicOnEmpty:
'Automatically show microphone button instead of send button when textarea is empty for models with audio modality support.',
pyInterpreterEnabled:
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.',
enableContinueGeneration: