diff --git a/tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessage.svelte b/tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessage.svelte index 52a9355104..d04a5fbb6c 100644 --- a/tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessage.svelte +++ b/tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessage.svelte @@ -6,6 +6,9 @@ import { conversationsStore } from '$lib/stores/conversations.svelte'; import { DatabaseService } from '$lib/services'; import { SYSTEM_MESSAGE_PLACEHOLDER } from '$lib/constants'; + import { AGENTIC_REGEX, TRIM_NEWLINES_REGEX } from '$lib/constants/agentic'; + import { copyToClipboard } from '$lib/utils/clipboard'; + import { config } from '$lib/stores/settings.svelte'; import { MessageRole, AttachmentType } from '$lib/enums'; import { ChatMessageAssistant, @@ -128,6 +131,18 @@ } function handleCopy() { + if ( + config().copyWithoutThinking && + message.role === MessageRole.ASSISTANT && + message.content + ) { + const stripped = message.content + .replace(AGENTIC_REGEX.REASONING_BLOCK, '') + .replace(AGENTIC_REGEX.REASONING_OPEN, '') + .replace(TRIM_NEWLINES_REGEX, ''); + void copyToClipboard(stripped); + return; + } chatActions.copy(message); } diff --git a/tools/server/webui/src/lib/components/app/chat/ChatSettings/ChatSettings.svelte b/tools/server/webui/src/lib/components/app/chat/ChatSettings/ChatSettings.svelte index 44d59e2b36..1cb7a758e0 100644 --- a/tools/server/webui/src/lib/components/app/chat/ChatSettings/ChatSettings.svelte +++ b/tools/server/webui/src/lib/components/app/chat/ChatSettings/ChatSettings.svelte @@ -69,6 +69,11 @@ label: 'Copy text attachments as plain text', type: SettingsFieldType.CHECKBOX }, + { + key: SETTINGS_KEYS.COPY_WITHOUT_THINKING, + label: 'Copy response without thinking content', + type: SettingsFieldType.CHECKBOX + }, { key: SETTINGS_KEYS.ENABLE_CONTINUE_GENERATION, label: 'Enable "Continue" button', diff --git a/tools/server/webui/src/lib/constants/settings-config.ts b/tools/server/webui/src/lib/constants/settings-config.ts index ae9dd3ce8f..b46d59d76d 100644 --- a/tools/server/webui/src/lib/constants/settings-config.ts +++ b/tools/server/webui/src/lib/constants/settings-config.ts @@ -16,6 +16,7 @@ export const SETTING_CONFIG_DEFAULT: Record = { 'On pasting long text, it will be converted to a file. You can control the file length by setting the value of this parameter. Value 0 means disable.', copyTextAttachmentsAsPlainText: 'When copying a message with text attachments, combine them into a single plain text string instead of a special format that can be pasted back as attachments.', + copyWithoutThinking: + 'When copying an assistant message, strip the thinking/reasoning block and only copy the final response.', samplers: 'The order at which samplers are applied, in simplified way. Default is "top_k;typ_p;top_p;min_p;temperature": top_k->typ_p->top_p->min_p->temperature', backend_sampling: diff --git a/tools/server/webui/src/lib/constants/settings-keys.ts b/tools/server/webui/src/lib/constants/settings-keys.ts index 1209103578..24b192400c 100644 --- a/tools/server/webui/src/lib/constants/settings-keys.ts +++ b/tools/server/webui/src/lib/constants/settings-keys.ts @@ -11,6 +11,7 @@ export const SETTINGS_KEYS = { SYSTEM_MESSAGE: 'systemMessage', PASTE_LONG_TEXT_TO_FILE_LEN: 'pasteLongTextToFileLen', COPY_TEXT_ATTACHMENTS_AS_PLAIN_TEXT: 'copyTextAttachmentsAsPlainText', + COPY_WITHOUT_THINKING: 'copyWithoutThinking', ENABLE_CONTINUE_GENERATION: 'enableContinueGeneration', PDF_AS_IMAGE: 'pdfAsImage', ASK_FOR_TITLE_CONFIRMATION: 'askForTitleConfirmation',