mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
feat: attach folder
This commit is contained in:
parent
fff0e55f41
commit
d2cb78179d
5 changed files with 39 additions and 14 deletions
|
|
@ -1181,8 +1181,18 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
if files or urls:
|
||||
if not files:
|
||||
files = []
|
||||
files = [*files, *[{"type": "url", "url": url, "name": url} for url in urls]]
|
||||
|
||||
for file_item in files:
|
||||
if file_item.get("type", "file") == "folder":
|
||||
# Get folder files
|
||||
folder_id = file_item.get("id", None)
|
||||
if folder_id:
|
||||
folder = Folders.get_folder_by_id_and_user_id(folder_id, user.id)
|
||||
if folder and folder.data and "files" in folder.data:
|
||||
files = [f for f in files if f.get("id", None) != folder_id]
|
||||
files = [*files, *folder.data["files"]]
|
||||
|
||||
files = [*files, *[{"type": "url", "url": url, "name": url} for url in urls]]
|
||||
# Remove duplicate files based on their content
|
||||
files = list({json.dumps(f, sort_keys=True): f for f in files}.values())
|
||||
|
||||
|
|
@ -1275,9 +1285,6 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
|
||||
def make_tool_function(client, function_name):
|
||||
async def tool_function(**kwargs):
|
||||
print(kwargs)
|
||||
print(client)
|
||||
print(await client.list_tool_specs())
|
||||
return await client.call_tool(
|
||||
function_name,
|
||||
function_args=kwargs,
|
||||
|
|
|
|||
|
|
@ -1547,7 +1547,7 @@
|
|||
|
||||
chatFiles.push(
|
||||
..._files.filter((item) =>
|
||||
['doc', 'text', 'file', 'note', 'chat', 'collection'].includes(item.type)
|
||||
['doc', 'text', 'file', 'note', 'chat', 'folder', 'collection'].includes(item.type)
|
||||
)
|
||||
);
|
||||
chatFiles = chatFiles.filter(
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
import Database from '$lib/components/icons/Database.svelte';
|
||||
import GlobeAlt from '$lib/components/icons/GlobeAlt.svelte';
|
||||
import Youtube from '$lib/components/icons/Youtube.svelte';
|
||||
import { folders } from '$lib/stores';
|
||||
import Folder from '$lib/components/icons/Folder.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
|
|
@ -144,14 +146,25 @@
|
|||
]
|
||||
: [];
|
||||
|
||||
items = [...collections, ...collection_files, ...legacy_collections, ...legacy_documents].map(
|
||||
(item) => {
|
||||
let folder_items = $folders.map((folder) => ({
|
||||
...folder,
|
||||
type: 'folder',
|
||||
description: $i18n.t('Folder'),
|
||||
title: folder.name
|
||||
}));
|
||||
|
||||
items = [
|
||||
...folder_items,
|
||||
...collections,
|
||||
...collection_files,
|
||||
...legacy_collections,
|
||||
...legacy_documents
|
||||
].map((item) => {
|
||||
return {
|
||||
...item,
|
||||
...(item?.legacy || item?.meta?.legacy || item?.meta?.document ? { legacy: true } : {})
|
||||
};
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
fuse = new Fuse(items, {
|
||||
keys: ['name', 'description']
|
||||
|
|
@ -213,6 +226,8 @@
|
|||
>
|
||||
{#if item?.type === 'collection'}
|
||||
<Database className="size-4" />
|
||||
{:else if item?.type === 'folder'}
|
||||
<Folder className="size-4" />
|
||||
{:else}
|
||||
<DocumentPage className="size-4" />
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
import Database from '../icons/Database.svelte';
|
||||
import PageEdit from '../icons/PageEdit.svelte';
|
||||
import ChatBubble from '../icons/ChatBubble.svelte';
|
||||
import Folder from '../icons/Folder.svelte';
|
||||
let showModal = false;
|
||||
|
||||
const decodeString = (str: string) => {
|
||||
|
|
@ -115,6 +116,8 @@
|
|||
<PageEdit />
|
||||
{:else if type === 'chat'}
|
||||
<ChatBubble />
|
||||
{:else if type === 'folder'}
|
||||
<Folder />
|
||||
{:else}
|
||||
<DocumentPage />
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
toast.error(`${error}`);
|
||||
return [];
|
||||
});
|
||||
_folders.set(folderList);
|
||||
_folders.set(folderList.sort((a, b) => b.updated_at - a.updated_at));
|
||||
|
||||
folders = {};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue