diff --git a/backend/open_webui/utils/task.py b/backend/open_webui/utils/task.py index 3b71ba746..21a30e416 100644 --- a/backend/open_webui/utils/task.py +++ b/backend/open_webui/utils/task.py @@ -122,7 +122,7 @@ def replace_messages_variable(template: str, messages: list[str]) -> str: def rag_template(template: str, context: str, query: str): - if template == "": + if template.strip() == "": template = DEFAULT_RAG_TEMPLATE if "[context]" not in template and "{{CONTEXT}}" not in template: diff --git a/src/lib/components/common/Textarea.svelte b/src/lib/components/common/Textarea.svelte index 254db2e4b..dfac6389a 100644 --- a/src/lib/components/common/Textarea.svelte +++ b/src/lib/components/common/Textarea.svelte @@ -25,7 +25,8 @@ function handlePaste(event: ClipboardEvent) { event.preventDefault(); // Prevent the default paste action const clipboardData = event.clipboardData?.getData('text/plain'); // Get plaintext from clipboard - document.execCommand('insertText', false, clipboardData); // Insert plaintext into contenteditable + + value = `${value}${clipboardData}`; // Append the plaintext to the current value } @@ -35,8 +36,8 @@ class="{className} whitespace-pre-wrap relative {!value.trim() ? 'placeholder' : ''}" style="field-sizing: content; -moz-user-select: text !important;" on:input={() => { - value = textareaElement.innerText; - console.log(value); + const text = textareaElement.innerText; + value = text.trim(); }} on:paste={handlePaste} data-placeholder={placeholder}