diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte
index 2aec58d4..3ba51a6f 100644
--- a/src/lib/components/chat/MessageInput.svelte
+++ b/src/lib/components/chat/MessageInput.svelte
@@ -295,7 +295,7 @@
files = [
...files,
{
- type: 'doc',
+ type: e?.detail?.type ?? 'doc',
...e.detail,
upload_status: true
}
@@ -446,6 +446,34 @@
Document
+ {:else if file.type === 'collection'}
+
+
+
+
+
+ #{file.name}
+
+
+
Collection
+
+
{/if}
diff --git a/src/lib/components/chat/MessageInput/Documents.svelte b/src/lib/components/chat/MessageInput/Documents.svelte
index 5f252b3d..6cc7bf4d 100644
--- a/src/lib/components/chat/MessageInput/Documents.svelte
+++ b/src/lib/components/chat/MessageInput/Documents.svelte
@@ -10,12 +10,35 @@
const dispatch = createEventDispatcher();
let selectedIdx = 0;
+
+ let filteredItems = [];
let filteredDocs = [];
+ let filteredTags = [];
+
+ let collections = [];
+
+ $: collections = $documents
+ .reduce((a, e, i, arr) => {
+ return [...new Set([...a, ...(e?.content?.tags ?? []).map((tag) => tag.name)])];
+ }, [])
+ .map((tag) => ({
+ name: tag,
+ type: 'collection',
+ collection_names: $documents
+ .filter((doc) => (doc?.content?.tags ?? []).map((tag) => tag.name).includes(tag))
+ .map((doc) => doc.collection_name)
+ }));
+
+ $: filteredCollections = collections
+ .filter((tag) => tag.name.includes(prompt.split(' ')?.at(0)?.substring(1) ?? ''))
+ .sort((a, b) => a.name.localeCompare(b.name));
$: filteredDocs = $documents
.filter((p) => p.name.includes(prompt.split(' ')?.at(0)?.substring(1) ?? ''))
.sort((a, b) => a.title.localeCompare(b.title));
+ $: filteredItems = [...filteredCollections, ...filteredDocs];
+
$: if (prompt) {
selectedIdx = 0;
}
@@ -25,7 +48,7 @@
};
export const selectDown = () => {
- selectedIdx = Math.min(selectedIdx + 1, filteredDocs.length - 1);
+ selectedIdx = Math.min(selectedIdx + 1, filteredItems.length - 1);
};
const confirmSelect = async (doc) => {
@@ -60,7 +83,7 @@
- {#each filteredDocs as doc, docIdx}
+ {#each filteredItems as doc, docIdx}
{/each}