mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-23 07:09:29 +01:00
refac
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
extractContentFromFile,
|
||||
extractCurlyBraceWords,
|
||||
extractInputVariables,
|
||||
getAge,
|
||||
getCurrentDateTime,
|
||||
getFormattedDate,
|
||||
getFormattedTime,
|
||||
@@ -73,6 +74,7 @@
|
||||
import { KokoroWorker } from '$lib/workers/KokoroWorker';
|
||||
import InputVariablesModal from './MessageInput/InputVariablesModal.svelte';
|
||||
import Voice from '../icons/Voice.svelte';
|
||||
import { getSessionUser } from '$lib/apis/auths';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let onChange: Function = () => {};
|
||||
@@ -176,11 +178,47 @@
|
||||
text = text.replaceAll('{{USER_LOCATION}}', String(location));
|
||||
}
|
||||
|
||||
const sessionUser = getSessionUser(localStorage.token);
|
||||
|
||||
if (text.includes('{{USER_NAME}}')) {
|
||||
const name = $_user?.name || 'User';
|
||||
const name = sessionUser?.name || 'User';
|
||||
text = text.replaceAll('{{USER_NAME}}', name);
|
||||
}
|
||||
|
||||
if (text.includes('{{USER_BIO}}')) {
|
||||
const bio = sessionUser?.bio || '';
|
||||
|
||||
if (bio) {
|
||||
text = text.replaceAll('{{USER_BIO}}', bio);
|
||||
}
|
||||
}
|
||||
|
||||
if (text.includes('{{USER_GENDER}}')) {
|
||||
const gender = sessionUser?.gender || '';
|
||||
|
||||
if (gender) {
|
||||
text = text.replaceAll('{{USER_GENDER}}', gender);
|
||||
}
|
||||
}
|
||||
|
||||
if (text.includes('{{USER_BIRTH_DATE}}')) {
|
||||
const birthDate = sessionUser?.date_of_birth || '';
|
||||
|
||||
if (birthDate) {
|
||||
text = text.replaceAll('{{USER_BIRTH_DATE}}', birthDate);
|
||||
}
|
||||
}
|
||||
|
||||
if (text.includes('{{USER_AGE}}')) {
|
||||
const birthDate = sessionUser?.date_of_birth || '';
|
||||
|
||||
if (birthDate) {
|
||||
// calculate age using date
|
||||
const age = getAge(birthDate);
|
||||
text = text.replaceAll('{{USER_AGE}}', age);
|
||||
}
|
||||
}
|
||||
|
||||
if (text.includes('{{USER_LANGUAGE}}')) {
|
||||
const language = localStorage.getItem('locale') || 'en-US';
|
||||
text = text.replaceAll('{{USER_LANGUAGE}}', language);
|
||||
@@ -872,7 +910,8 @@
|
||||
: `${WEBUI_BASE_URL}/static/favicon.png`)}
|
||||
/>
|
||||
<div class="translate-y-[0.5px]">
|
||||
{$i18n.t('Talk to model')}: <span class=" font-medium">{atSelectedModel.name}</span>
|
||||
{$i18n.t('Talk to model')}:
|
||||
<span class=" font-medium">{atSelectedModel.name}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user