From 5a0488bb183c2e5337762053b0b6d4567497e4ed Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 22 Jan 2026 17:30:07 +0100 Subject: [PATCH] init (#20881) --- backend/open_webui/utils/task.py | 4 ++++ src/lib/components/channel/MessageInput.svelte | 8 ++++++++ src/lib/components/chat/MessageInput.svelte | 8 ++++++++ src/lib/utils/index.ts | 17 +++++++++-------- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/backend/open_webui/utils/task.py b/backend/open_webui/utils/task.py index ecedd595a..4acb2c371 100644 --- a/backend/open_webui/utils/task.py +++ b/backend/open_webui/utils/task.py @@ -69,6 +69,7 @@ def prompt_template(template: str, user: Optional[Any] = None) -> str: USER_VARIABLES = { "name": str(user.get("name")), + "email": str(user.get("email")), "location": str(user_info.get("location")), "bio": str(user.get("bio")), "gender": str(user.get("gender")), @@ -92,6 +93,9 @@ def prompt_template(template: str, user: Optional[Any] = None) -> str: template = template.replace("{{CURRENT_WEEKDAY}}", formatted_weekday) template = template.replace("{{USER_NAME}}", USER_VARIABLES.get("name", "Unknown")) + template = template.replace( + "{{USER_EMAIL}}", USER_VARIABLES.get("email", "Unknown") + ) template = template.replace("{{USER_BIO}}", USER_VARIABLES.get("bio", "Unknown")) template = template.replace( "{{USER_GENDER}}", USER_VARIABLES.get("gender", "Unknown") diff --git a/src/lib/components/channel/MessageInput.svelte b/src/lib/components/channel/MessageInput.svelte index bff703c51..2b6c2b96f 100644 --- a/src/lib/components/channel/MessageInput.svelte +++ b/src/lib/components/channel/MessageInput.svelte @@ -147,6 +147,14 @@ text = text.replaceAll('{{USER_NAME}}', name); } + if (text.includes('{{USER_EMAIL}}')) { + const email = sessionUser?.email || ''; + + if (email) { + text = text.replaceAll('{{USER_EMAIL}}', email); + } + } + if (text.includes('{{USER_BIO}}')) { const bio = sessionUser?.bio || ''; diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index d02bda4fa..103da88f9 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -221,6 +221,14 @@ text = text.replaceAll('{{USER_NAME}}', name); } + if (text.includes('{{USER_EMAIL}}')) { + const email = sessionUser?.email || ''; + + if (email) { + text = text.replaceAll('{{USER_EMAIL}}', email); + } + } + if (text.includes('{{USER_BIO}}')) { const bio = sessionUser?.bio || ''; diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 265c47cec..2ea221ab8 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -357,9 +357,9 @@ export const generateInitialsImage = (name) => { const initials = sanitizedName.length > 0 ? sanitizedName[0] + - (sanitizedName.split(' ').length > 1 - ? sanitizedName[sanitizedName.lastIndexOf(' ') + 1] - : '') + (sanitizedName.split(' ').length > 1 + ? sanitizedName[sanitizedName.lastIndexOf(' ') + 1] + : '') : ''; ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2); @@ -515,10 +515,10 @@ export const compareVersion = (latest, current) => { return current === '0.0.0' ? false : current.localeCompare(latest, undefined, { - numeric: true, - sensitivity: 'case', - caseFirst: 'upper' - }) < 0; + numeric: true, + sensitivity: 'case', + caseFirst: 'upper' + }) < 0; }; export const extractCurlyBraceWords = (text) => { @@ -973,9 +973,10 @@ export const blobToFile = (blob, fileName) => { return file; }; -export const getPromptVariables = (user_name, user_location) => { +export const getPromptVariables = (user_name, user_location, user_email = '') => { return { '{{USER_NAME}}': user_name, + '{{USER_EMAIL}}': user_email || 'Unknown', '{{USER_LOCATION}}': user_location || 'Unknown', '{{CURRENT_DATETIME}}': getCurrentDateTime(), '{{CURRENT_DATE}}': getFormattedDate(),