From ea883b2ed43536b8033bfb27419618b8a653548b Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 27 Nov 2024 19:38:57 -0800 Subject: [PATCH] refac --- backend/open_webui/main.py | 2 +- src/lib/components/common/Textarea.svelte | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index aa936db47..d8c246dc3 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1942,7 +1942,7 @@ async def generate_queries(form_data: dict, user=Depends(get_verified_user)): f"generating {type} queries using model {task_model_id} for user {user.email}" ) - if app.state.config.QUERY_GENERATION_PROMPT_TEMPLATE != "": + if (app.state.config.QUERY_GENERATION_PROMPT_TEMPLATE).strip() != "": template = app.state.config.QUERY_GENERATION_PROMPT_TEMPLATE else: template = DEFAULT_QUERY_GENERATION_PROMPT_TEMPLATE diff --git a/src/lib/components/common/Textarea.svelte b/src/lib/components/common/Textarea.svelte index c073d84eb..577342daf 100644 --- a/src/lib/components/common/Textarea.svelte +++ b/src/lib/components/common/Textarea.svelte @@ -3,15 +3,13 @@ export let value = ''; export let placeholder = ''; - export let rows = 1; - export let required = false; export let className = 'w-full rounded-lg px-3 py-2 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none resize-none h-full'; let textareaElement; $: if (textareaElement) { - if (textareaElement.innerText !== value) { + if (textareaElement.innerText !== value && value !== '') { textareaElement.innerText = value; } } @@ -38,11 +36,12 @@ style="field-sizing: content; -moz-user-select: text !important;" on:input={() => { const text = textareaElement.innerText; - if (text.trim() === '\n') { + if (text === '\n') { value = ''; return; } - value = text.trim(); + + value = text; }} on:paste={handlePaste} data-placeholder={placeholder}