mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 00:59:52 +00:00
enh: knowledge collection search
This commit is contained in:
parent
263cc71dd3
commit
f3ee07a8a2
@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import Fuse from 'fuse.js';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
import { onMount, getContext, onDestroy } from 'svelte';
|
||||
@ -50,6 +51,21 @@
|
||||
let showAddTextContentModal = false;
|
||||
let inputFiles = null;
|
||||
|
||||
let filteredItems = [];
|
||||
$: if (knowledge) {
|
||||
fuse = new Fuse(knowledge.files, {
|
||||
keys: ['meta.name', 'meta.description']
|
||||
});
|
||||
}
|
||||
|
||||
$: if (fuse) {
|
||||
filteredItems = query
|
||||
? fuse.search(query).map((e) => {
|
||||
return e.item;
|
||||
})
|
||||
: (knowledge?.files ?? []);
|
||||
}
|
||||
|
||||
let selectedFile = null;
|
||||
let selectedFileId = null;
|
||||
|
||||
@ -63,6 +79,7 @@
|
||||
selectedFile = null;
|
||||
}
|
||||
|
||||
let fuse = null;
|
||||
let debounceTimeout = null;
|
||||
let mediaQuery;
|
||||
let dragged = false;
|
||||
@ -408,10 +425,10 @@
|
||||
<hr class=" mt-2 mb-1 border-gray-50 dark:border-gray-850" />
|
||||
</div>
|
||||
|
||||
{#if (knowledge?.files ?? []).length > 0}
|
||||
{#if filteredItems.length > 0}
|
||||
<div class=" flex overflow-y-auto h-full w-full scrollbar-hidden text-xs">
|
||||
<Files
|
||||
files={knowledge.files}
|
||||
files={filteredItems}
|
||||
{selectedFileId}
|
||||
on:click={(e) => {
|
||||
selectedFileId = e.detail;
|
||||
|
Loading…
Reference in New Issue
Block a user