Spaces:
Running
Running
Enable dropzone on tools (#1211)
Browse files* Enable file dropzone on tools
* Change text based on tools or multimodal
* lint
* comment
src/lib/components/chat/ChatWindow.svelte
CHANGED
@@ -301,8 +301,12 @@
|
|
301 |
class="relative flex w-full max-w-4xl flex-1 items-center rounded-xl border bg-gray-100 focus-within:border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:focus-within:border-gray-500
|
302 |
{isReadOnly ? 'opacity-30' : ''}"
|
303 |
>
|
304 |
-
{#if onDrag && currentModel.multimodal}
|
305 |
-
<FileDropzone
|
|
|
|
|
|
|
|
|
306 |
{:else}
|
307 |
<div class="flex w-full flex-1 border-none bg-transparent">
|
308 |
{#if lastIsError}
|
|
|
301 |
class="relative flex w-full max-w-4xl flex-1 items-center rounded-xl border bg-gray-100 focus-within:border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:focus-within:border-gray-500
|
302 |
{isReadOnly ? 'opacity-30' : ''}"
|
303 |
>
|
304 |
+
{#if onDrag && (currentModel.multimodal || currentModel.tools)}
|
305 |
+
<FileDropzone
|
306 |
+
bind:files
|
307 |
+
bind:onDrag
|
308 |
+
onlyImages={currentModel.multimodal && !currentModel.tools}
|
309 |
+
/>
|
310 |
{:else}
|
311 |
<div class="flex w-full flex-1 border-none bg-transparent">
|
312 |
{#if lastIsError}
|
src/lib/components/chat/FileDropzone.svelte
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
// import EosIconsLoading from "~icons/eos-icons/loading";
|
5 |
|
6 |
export let files: File[];
|
|
|
7 |
|
8 |
let file_error_message = "";
|
9 |
let errorTimeout: ReturnType<typeof setTimeout>;
|
@@ -23,13 +24,13 @@
|
|
23 |
if (event.dataTransfer.items[0].kind === "file") {
|
24 |
const file = event.dataTransfer.items[0].getAsFile();
|
25 |
if (file) {
|
26 |
-
if (!event.dataTransfer.items[0].type.startsWith("image")) {
|
27 |
setErrorMsg("Only images are supported");
|
28 |
files = [];
|
29 |
return;
|
30 |
}
|
31 |
-
// if
|
32 |
-
if (file.size >
|
33 |
setErrorMsg("Image is too big. (2MB max)");
|
34 |
files = [];
|
35 |
return;
|
@@ -88,7 +89,7 @@
|
|
88 |
class="mb-3 mt-1.5 text-sm text-gray-500 dark:text-gray-400"
|
89 |
class:opacity-0={file_error_message}
|
90 |
>
|
91 |
-
Drag and drop <span class="font-semibold">one image</span> here
|
92 |
</p>
|
93 |
</div>
|
94 |
</div>
|
|
|
4 |
// import EosIconsLoading from "~icons/eos-icons/loading";
|
5 |
|
6 |
export let files: File[];
|
7 |
+
export let onlyImages: boolean = false;
|
8 |
|
9 |
let file_error_message = "";
|
10 |
let errorTimeout: ReturnType<typeof setTimeout>;
|
|
|
24 |
if (event.dataTransfer.items[0].kind === "file") {
|
25 |
const file = event.dataTransfer.items[0].getAsFile();
|
26 |
if (file) {
|
27 |
+
if (!event.dataTransfer.items[0].type.startsWith("image") && onlyImages) {
|
28 |
setErrorMsg("Only images are supported");
|
29 |
files = [];
|
30 |
return;
|
31 |
}
|
32 |
+
// if file is bigger than 10MB abort
|
33 |
+
if (file.size > 10 * 1024 * 1024) {
|
34 |
setErrorMsg("Image is too big. (2MB max)");
|
35 |
files = [];
|
36 |
return;
|
|
|
89 |
class="mb-3 mt-1.5 text-sm text-gray-500 dark:text-gray-400"
|
90 |
class:opacity-0={file_error_message}
|
91 |
>
|
92 |
+
Drag and drop <span class="font-semibold">one {onlyImages ? "image" : "file"}</span> here
|
93 |
</p>
|
94 |
</div>
|
95 |
</div>
|