- |
+ |
{chat.title}
@@ -88,11 +137,16 @@
|
-
+ |
{dayjs(chat.created_at * 1000).format($i18n.t('MMMM DD, YYYY HH:mm'))}
|
+
+
+ {dayjs(chat.updated_at * 1000).format($i18n.t('MMMM DD, YYYY HH:mm'))}
+
+ |
diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte
index 73b480796e..d83eb3cb2f 100644
--- a/src/lib/components/chat/Chat.svelte
+++ b/src/lib/components/chat/Chat.svelte
@@ -31,6 +31,7 @@
convertMessagesToHistory,
copyToClipboard,
extractSentencesForAudio,
+ getUserPosition,
promptTemplate,
splitStream
} from '$lib/utils';
@@ -50,7 +51,7 @@
import { runWebSearch } from '$lib/apis/rag';
import { createOpenAITextStream } from '$lib/apis/streaming';
import { queryMemory } from '$lib/apis/memories';
- import { getUserSettings } from '$lib/apis/users';
+ import { getAndUpdateUserLocation, getUserSettings } from '$lib/apis/users';
import { chatCompleted, generateTitle, generateSearchQuery } from '$lib/apis';
import Banner from '../common/Banner.svelte';
@@ -272,11 +273,14 @@
id: m.id,
role: m.role,
content: m.content,
+ info: m.info ? m.info : undefined,
timestamp: m.timestamp
})),
chat_id: $chatId
}).catch((error) => {
- console.error(error);
+ toast.error(error);
+ messages.at(-1).error = { content: error };
+
return null;
});
@@ -321,9 +325,16 @@
} else if (messages.length != 0 && messages.at(-1).done != true) {
// Response not done
console.log('wait');
+ } else if (messages.length != 0 && messages.at(-1).error) {
+ // Error in response
+ toast.error(
+ $i18n.t(
+ `Oops! There was an error in the previous response. Please try again or contact admin.`
+ )
+ );
} else if (
files.length > 0 &&
- files.filter((file) => file.upload_status === false).length > 0
+ files.filter((file) => file.type !== 'image' && file.status !== 'processed').length > 0
) {
// Upload not done
toast.error(
@@ -533,7 +544,13 @@
$settings.system || (responseMessage?.userContext ?? null)
? {
role: 'system',
- content: `${promptTemplate($settings?.system ?? '', $user.name)}${
+ content: `${promptTemplate(
+ $settings?.system ?? '',
+ $user.name,
+ $settings?.userLocation
+ ? await getAndUpdateUserLocation(localStorage.token)
+ : undefined
+ )}${
responseMessage?.userContext ?? null
? `\n\nUser Context:\n${(responseMessage?.userContext ?? []).join('\n')}`
: ''
@@ -578,23 +595,18 @@
}
});
- let docs = [];
-
+ let files = [];
if (model?.info?.meta?.knowledge ?? false) {
- docs = model.info.meta.knowledge;
+ files = model.info.meta.knowledge;
}
-
- docs = [
- ...docs,
- ...messages
- .filter((message) => message?.files ?? null)
- .map((message) =>
- message.files.filter((item) =>
- ['doc', 'collection', 'web_search_results'].includes(item.type)
- )
- )
- .flat(1)
+ const lastUserMessage = messages.filter((message) => message.role === 'user').at(-1);
+ files = [
+ ...files,
+ ...(lastUserMessage?.files?.filter((item) =>
+ ['doc', 'file', 'collection', 'web_search_results'].includes(item.type)
+ ) ?? [])
].filter(
+ // Remove duplicates
(item, index, array) =>
array.findIndex((i) => JSON.stringify(i) === JSON.stringify(item)) === index
);
@@ -626,8 +638,8 @@
format: $settings.requestFormat ?? undefined,
keep_alive: $settings.keepAlive ?? undefined,
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
- docs: docs.length > 0 ? docs : undefined,
- citations: docs.length > 0,
+ files: files.length > 0 ? files : undefined,
+ citations: files.length > 0 ? true : undefined,
chat_id: $chatId
});
@@ -823,23 +835,18 @@
let _response = null;
const responseMessage = history.messages[responseMessageId];
- let docs = [];
-
+ let files = [];
if (model?.info?.meta?.knowledge ?? false) {
- docs = model.info.meta.knowledge;
+ files = model.info.meta.knowledge;
}
-
- docs = [
- ...docs,
- ...messages
- .filter((message) => message?.files ?? null)
- .map((message) =>
- message.files.filter((item) =>
- ['doc', 'collection', 'web_search_results'].includes(item.type)
- )
- )
- .flat(1)
+ const lastUserMessage = messages.filter((message) => message.role === 'user').at(-1);
+ files = [
+ ...files,
+ ...(lastUserMessage?.files?.filter((item) =>
+ ['doc', 'file', 'collection', 'web_search_results'].includes(item.type)
+ ) ?? [])
].filter(
+ // Remove duplicates
(item, index, array) =>
array.findIndex((i) => JSON.stringify(i) === JSON.stringify(item)) === index
);
@@ -871,7 +878,13 @@
$settings.system || (responseMessage?.userContext ?? null)
? {
role: 'system',
- content: `${promptTemplate($settings?.system ?? '', $user.name)}${
+ content: `${promptTemplate(
+ $settings?.system ?? '',
+ $user.name,
+ $settings?.userLocation
+ ? await getAndUpdateUserLocation(localStorage.token)
+ : undefined
+ )}${
responseMessage?.userContext ?? null
? `\n\nUser Context:\n${(responseMessage?.userContext ?? []).join('\n')}`
: ''
@@ -923,11 +936,12 @@
frequency_penalty: $settings?.params?.frequency_penalty ?? undefined,
max_tokens: $settings?.params?.max_tokens ?? undefined,
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
- docs: docs.length > 0 ? docs : undefined,
- citations: docs.length > 0,
+ files: files.length > 0 ? files : undefined,
+ citations: files.length > 0 ? true : undefined,
+
chat_id: $chatId
},
- `${OPENAI_API_BASE_URL}`
+ `${WEBUI_BASE_URL}/api`
);
// Wait until history/message have been updated
@@ -1309,6 +1323,19 @@
? 'md:max-w-[calc(100%-260px)]'
: ''} w-full max-w-full flex flex-col"
>
+ {#if $settings?.backgroundImageUrl ?? null}
+
+
+
+ {/if}
+
0 && messages.length === 0 && !$chatId && selectedModels.length <= 1}
|