This commit is contained in:
Timothy J. Baek
2024-08-27 17:05:24 +02:00
parent 628310b12b
commit 6a21a77ee9
6 changed files with 107 additions and 36 deletions
+21
View File
@@ -542,6 +542,27 @@
`Oops! Hold tight! Your files are still in the processing oven. We're cooking them up to perfection. Please be patient and we'll let you know once they're ready.`
)
);
} else if (
($config?.file?.max_count ?? null) !== null &&
files.length + chatFiles.length > $config?.file?.max_count
) {
console.log(chatFiles.length, files.length);
toast.error(
$i18n.t(`You can only chat with a maximum of {{maxCount}} file(s) at a time.`, {
maxCount: $config?.file?.max_count
})
);
} else if (
($config?.file?.max_size ?? null) !== null &&
[...files, ...chatFiles].some(
(file) => file.size > ($config?.file?.max_size ?? 0) * 1024 * 1024
)
) {
toast.error(
$i18n.t(`File size should not exceed {{maxSize}} MB.`, {
maxSize: $config?.file?.max_size
})
);
} else {
// Reset chat input textarea
const chatTextAreaElement = document.getElementById('chat-textarea');
+14 -1
View File
@@ -173,6 +173,20 @@
const inputFilesHandler = async (inputFiles) => {
inputFiles.forEach((file) => {
console.log(file, file.name.split('.').at(-1));
if (
($config?.file?.max_size ?? null) !== null &&
file.size > ($config?.file?.max_size ?? 0) * 1024 * 1024
) {
toast.error(
$i18n.t(`File size should not exceed {{maxSize}} MB.`, {
maxSize: $config?.file?.max_size
})
);
return;
}
if (['image/gif', 'image/webp', 'image/jpeg', 'image/png'].includes(file['type'])) {
if (visionCapableModels.length === 0) {
toast.error($i18n.t('Selected model(s) do not support image inputs'));
@@ -222,7 +236,6 @@
if (e.dataTransfer?.files) {
const inputFiles = Array.from(e.dataTransfer?.files);
console.log(file, file.name.split('.').at(-1));
if (inputFiles && inputFiles.length > 0) {
console.log(inputFiles);
inputFilesHandler(inputFiles);