mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 14:25:19 +00:00
refac/fix: web/youtube file attachment handling
This commit is contained in:
parent
2227f24bd6
commit
210197fd43
2 changed files with 34 additions and 20 deletions
|
|
@ -491,11 +491,23 @@ def get_sources_from_items(
|
||||||
# Raw Text
|
# Raw Text
|
||||||
# Used during temporary chat file uploads or web page & youtube attachements
|
# Used during temporary chat file uploads or web page & youtube attachements
|
||||||
|
|
||||||
|
if item.get("context") == "full":
|
||||||
|
if item.get("file"):
|
||||||
|
# if item has file data, use it
|
||||||
|
query_result = {
|
||||||
|
"documents": [
|
||||||
|
[item.get("file", {}).get("data", {}).get("content")]
|
||||||
|
],
|
||||||
|
"metadatas": [[item.get("file", {}).get("meta", {})]],
|
||||||
|
}
|
||||||
|
|
||||||
|
if query_result is None:
|
||||||
|
# Fallback
|
||||||
if item.get("collection_name"):
|
if item.get("collection_name"):
|
||||||
# If item has a collection name, use it
|
# If item has a collection name, use it
|
||||||
collection_names.append(item.get("collection_name"))
|
collection_names.append(item.get("collection_name"))
|
||||||
elif item.get("file"):
|
elif item.get("file"):
|
||||||
# if item has file data, use it
|
# If item has file data, use it
|
||||||
query_result = {
|
query_result = {
|
||||||
"documents": [
|
"documents": [
|
||||||
[item.get("file", {}).get("data", {}).get("content")]
|
[item.get("file", {}).get("data", {}).get("content")]
|
||||||
|
|
|
||||||
|
|
@ -1466,7 +1466,9 @@
|
||||||
const messages = createMessagesList(history, history.currentId);
|
const messages = createMessagesList(history, history.currentId);
|
||||||
const _files = JSON.parse(JSON.stringify(files));
|
const _files = JSON.parse(JSON.stringify(files));
|
||||||
|
|
||||||
chatFiles.push(..._files.filter((item) => ['doc', 'file', 'collection'].includes(item.type)));
|
chatFiles.push(
|
||||||
|
..._files.filter((item) => ['doc', 'text', 'file', 'collection'].includes(item.type))
|
||||||
|
);
|
||||||
chatFiles = chatFiles.filter(
|
chatFiles = chatFiles.filter(
|
||||||
// Remove duplicates
|
// Remove duplicates
|
||||||
(item, index, array) =>
|
(item, index, array) =>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue