Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
c9ed934d
Commit
c9ed934d
authored
Aug 01, 2024
by
Timothy J. Baek
Browse files
refac: file should not have 'uploaded' status
parent
6681df29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
src/lib/components/chat/MessageInput.svelte
src/lib/components/chat/MessageInput.svelte
+7
-9
No files found.
src/lib/components/chat/MessageInput.svelte
View file @
c9ed934d
<script lang="ts">
<script lang="ts">
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import { v4 as uuidv4 } from 'uuid';
import { onMount, tick, getContext } from 'svelte';
import { onMount, tick, getContext } from 'svelte';
import {
import {
type Model,
type Model,
...
@@ -99,7 +98,6 @@
...
@@ -99,7 +98,6 @@
const uploadFileHandler = async (file) => {
const uploadFileHandler = async (file) => {
console.log(file);
console.log(file);
const fileId = uuidv4();
// Check if the file is an audio file and transcribe/convert it to text file
// Check if the file is an audio file and transcribe/convert it to text file
if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
...
@@ -118,11 +116,11 @@
...
@@ -118,11 +116,11 @@
const fileItem = {
const fileItem = {
type: 'file',
type: 'file',
file: '',
file: '',
id:
fileId
,
id:
null
,
url: '',
url: '',
name: file.name,
name: file.name,
collection_name: '',
collection_name: '',
status: '
uploaded
',
status: '',
size: file.size,
size: file.size,
error: ''
error: ''
};
};
...
@@ -132,6 +130,7 @@
...
@@ -132,6 +130,7 @@
const uploadedFile = await uploadFile(localStorage.token, file);
const uploadedFile = await uploadFile(localStorage.token, file);
if (uploadedFile) {
if (uploadedFile) {
fileItem.status = 'uploaded';
fileItem.file = uploadedFile;
fileItem.file = uploadedFile;
fileItem.id = uploadedFile.id;
fileItem.id = uploadedFile.id;
fileItem.url = `${WEBUI_API_BASE_URL}/files/${uploadedFile.id}`;
fileItem.url = `${WEBUI_API_BASE_URL}/files/${uploadedFile.id}`;
...
@@ -152,11 +151,11 @@
...
@@ -152,11 +151,11 @@
processFileItem(fileItem);
processFileItem(fileItem);
}
}
} else {
} else {
files = files.filter((item) => item.
id !== fileId
);
files = files.filter((item) => item.
status !== null
);
}
}
} catch (e
rror
) {
} catch (e) {
toast.error(e
rror
);
toast.error(e);
files = files.filter((item) => item.
id !== fileId
);
files = files.filter((item) => item.
status !== null
);
}
}
};
};
...
@@ -173,7 +172,6 @@
...
@@ -173,7 +172,6 @@
// Remove the failed doc from the files array
// Remove the failed doc from the files array
// files = files.filter((f) => f.id !== fileItem.id);
// files = files.filter((f) => f.id !== fileItem.id);
toast.error(e);
toast.error(e);
fileItem.status = 'processed';
fileItem.status = 'processed';
files = files;
files = files;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment