mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: rename projects -> knowledge
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
|
||||
export const createNewProject = async (token: string, name: string, description: string) => {
|
||||
export const createNewKnowledge = async (token: string, name: string, description: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/projects/create`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/knowledge/create`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@@ -32,10 +32,10 @@ export const createNewProject = async (token: string, name: string, description:
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getProjects = async (token: string = '') => {
|
||||
export const getKnowledgeItems = async (token: string = '') => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/projects/`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/knowledge/`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@@ -63,10 +63,10 @@ export const getProjects = async (token: string = '') => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getProjectById = async (token: string, id: string) => {
|
||||
export const getKnowledgeById = async (token: string, id: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/projects/${id}`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/knowledge/${id}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@@ -95,14 +95,16 @@ export const getProjectById = async (token: string, id: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
type ProjectForm = {
|
||||
type KnowledgeForm = {
|
||||
name: string;
|
||||
description: string;
|
||||
data: object;
|
||||
};
|
||||
|
||||
export const updateProjectById = async (token: string, id: string, form: ProjectForm) => {
|
||||
export const updateKnowledgeById = async (token: string, id: string, form: KnowledgeForm) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/projects/${id}/update`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/knowledge/${id}/update`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@@ -110,7 +112,9 @@ export const updateProjectById = async (token: string, id: string, form: Project
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: form.name
|
||||
name: form.name,
|
||||
description: form.description,
|
||||
data: form.data
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
@@ -134,10 +138,10 @@ export const updateProjectById = async (token: string, id: string, form: Project
|
||||
return res;
|
||||
};
|
||||
|
||||
export const deleteProjectById = async (token: string, id: string) => {
|
||||
export const deleteKnowledgeById = async (token: string, id: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/projects/${id}/delete`, {
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/knowledge/${id}/delete`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@@ -19,8 +19,8 @@
|
||||
updateRAGConfig
|
||||
} from '$lib/apis/retrieval';
|
||||
|
||||
import { projects, models } from '$lib/stores';
|
||||
import { getProjects } from '$lib/apis/projects';
|
||||
import { knowledge, models } from '$lib/stores';
|
||||
import { getKnowledgeItems } from '$lib/apis/knowledge';
|
||||
import { deleteAllFiles, deleteFileById } from '$lib/apis/files';
|
||||
|
||||
import ResetUploadDirConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
||||
@@ -69,7 +69,7 @@
|
||||
scanDirLoading = false;
|
||||
|
||||
if (res) {
|
||||
await projects.set(await getProjects(localStorage.token));
|
||||
await knowledge.set(await getKnowledgeItems(localStorage.token));
|
||||
toast.success($i18n.t('Scan complete!'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
import Prompts from './Commands/Prompts.svelte';
|
||||
import Projects from './Commands/Projects.svelte';
|
||||
import Knowledge from './Commands/Knowledge.svelte';
|
||||
import Models from './Commands/Models.svelte';
|
||||
|
||||
import { removeLastWordFromString } from '$lib/utils';
|
||||
@@ -97,7 +97,7 @@
|
||||
{#if command?.charAt(0) === '/'}
|
||||
<Prompts bind:this={commandElement} bind:prompt bind:files {command} />
|
||||
{:else if command?.charAt(0) === '#'}
|
||||
<Projects
|
||||
<Knowledge
|
||||
bind:this={commandElement}
|
||||
bind:prompt
|
||||
{command}
|
||||
@@ -114,7 +114,7 @@
|
||||
files = [
|
||||
...files,
|
||||
{
|
||||
type: e?.detail?.meta?.document ? 'file' : 'project',
|
||||
type: e?.detail?.meta?.document ? 'file' : 'collection',
|
||||
...e.detail,
|
||||
status: 'processed'
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { createEventDispatcher, tick, getContext, onMount } from 'svelte';
|
||||
import { removeLastWordFromString, isValidHttpUrl } from '$lib/utils';
|
||||
import { projects } from '$lib/stores';
|
||||
import { knowledge } from '$lib/stores';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
let fuse = null;
|
||||
|
||||
let filteredProjects = [];
|
||||
let filteredItems = [];
|
||||
$: if (fuse) {
|
||||
filteredProjects = command.slice(1)
|
||||
filteredItems = command.slice(1)
|
||||
? fuse.search(command).map((e) => {
|
||||
return e.item;
|
||||
})
|
||||
: $projects;
|
||||
: $knowledge;
|
||||
}
|
||||
|
||||
$: if (command) {
|
||||
@@ -34,7 +34,7 @@
|
||||
};
|
||||
|
||||
export const selectDown = () => {
|
||||
selectedIdx = Math.min(selectedIdx + 1, filteredProjects.length - 1);
|
||||
selectedIdx = Math.min(selectedIdx + 1, filteredItems.length - 1);
|
||||
};
|
||||
|
||||
const confirmSelect = async (item) => {
|
||||
@@ -71,13 +71,13 @@
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
fuse = new Fuse($projects, {
|
||||
fuse = new Fuse($knowledge, {
|
||||
keys: ['name', 'description']
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if filteredProjects.length > 0 || prompt.split(' ')?.at(0)?.substring(1).startsWith('http')}
|
||||
{#if filteredItems.length > 0 || prompt.split(' ')?.at(0)?.substring(1).startsWith('http')}
|
||||
<div
|
||||
id="commands-container"
|
||||
class="pl-1 pr-12 mb-3 text-left w-full absolute bottom-0 left-0 right-0 z-10"
|
||||
@@ -91,15 +91,15 @@
|
||||
class="max-h-60 flex flex-col w-full rounded-r-xl bg-white dark:bg-gray-900 dark:text-gray-100"
|
||||
>
|
||||
<div class="m-1 overflow-y-auto p-1 rounded-r-xl space-y-0.5 scrollbar-hidden">
|
||||
{#each filteredProjects as project, idx}
|
||||
{#each filteredItems as item, idx}
|
||||
<button
|
||||
class=" px-3 py-1.5 rounded-xl w-full text-left {idx === selectedIdx
|
||||
? ' bg-gray-50 dark:bg-gray-850 dark:text-gray-100 selected-command-option-button'
|
||||
: ''}"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log(project);
|
||||
confirmSelect(project);
|
||||
console.log(item);
|
||||
confirmSelect(item);
|
||||
}}
|
||||
on:mousemove={() => {
|
||||
selectedIdx = idx;
|
||||
@@ -108,10 +108,10 @@
|
||||
>
|
||||
<div class=" font-medium text-black dark:text-gray-100 flex items-center gap-1">
|
||||
<div class="line-clamp-1">
|
||||
{project.name}
|
||||
{item.name}
|
||||
</div>
|
||||
|
||||
{#if project?.meta?.document}
|
||||
{#if item?.meta?.document}
|
||||
<div
|
||||
class="bg-gray-500/20 text-gray-700 dark:text-gray-200 rounded uppercase text-xs px-1"
|
||||
>
|
||||
@@ -121,13 +121,13 @@
|
||||
<div
|
||||
class="bg-green-500/20 text-green-700 dark:text-green-200 rounded uppercase text-xs px-1"
|
||||
>
|
||||
Project
|
||||
Collection
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class=" text-xs text-gray-600 dark:text-gray-100 line-clamp-1">
|
||||
{project.description}
|
||||
{item.description}
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
@@ -7,9 +7,9 @@
|
||||
import { onMount, getContext } from 'svelte';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
import { WEBUI_NAME, projects } from '$lib/stores';
|
||||
import { WEBUI_NAME, knowledge } from '$lib/stores';
|
||||
|
||||
import { getProjects, deleteProjectById } from '$lib/apis/projects';
|
||||
import { getKnowledgeItems, deleteKnowledgeById } from '$lib/apis/knowledge';
|
||||
|
||||
import { blobToFile, transformFileName } from '$lib/utils';
|
||||
|
||||
@@ -18,50 +18,50 @@
|
||||
import GarbageBin from '../icons/GarbageBin.svelte';
|
||||
import Pencil from '../icons/Pencil.svelte';
|
||||
import DeleteConfirmDialog from '../common/ConfirmDialog.svelte';
|
||||
import ProjectMenu from './Projects/ProjectMenu.svelte';
|
||||
import ItemMenu from './Knowledge/ItemMenu.svelte';
|
||||
|
||||
let query = '';
|
||||
let selectedProject = null;
|
||||
let selectedItem = null;
|
||||
let showDeleteConfirm = false;
|
||||
|
||||
let filteredProjects;
|
||||
$: filteredProjects = $projects.filter((project) => query === '' || project.name.includes(query));
|
||||
let filteredItems;
|
||||
$: filteredItems = $knowledge.filter((item) => query === '' || item.name.includes(query));
|
||||
|
||||
const deleteHandler = async (project) => {
|
||||
const res = await deleteProjectById(localStorage.token, project.id).catch((e) => {
|
||||
const deleteHandler = async (item) => {
|
||||
const res = await deleteKnowledgeById(localStorage.token, item.id).catch((e) => {
|
||||
toast.error(e);
|
||||
});
|
||||
|
||||
if (res) {
|
||||
projects.set(await getProjects(localStorage.token));
|
||||
toast.success($i18n.t('Project deleted successfully.'));
|
||||
knowledge.set(await getKnowledgeItems(localStorage.token));
|
||||
toast.success($i18n.t('Knowledge deleted successfully.'));
|
||||
}
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
projects.set(await getProjects(localStorage.token));
|
||||
knowledge.set(await getKnowledgeItems(localStorage.token));
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>
|
||||
{$i18n.t('Projects')} | {$WEBUI_NAME}
|
||||
{$i18n.t('Knowledge')} | {$WEBUI_NAME}
|
||||
</title>
|
||||
</svelte:head>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
bind:show={showDeleteConfirm}
|
||||
on:confirm={() => {
|
||||
deleteHandler(selectedProject);
|
||||
deleteHandler(selectedItem);
|
||||
}}
|
||||
/>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex md:self-center text-lg font-medium px-0.5">
|
||||
{$i18n.t('Projects')}
|
||||
{$i18n.t('Knowledge')}
|
||||
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-200 dark:bg-gray-700" />
|
||||
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{$projects.length}</span>
|
||||
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{$knowledge.length}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,16 +85,16 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-none bg-transparent"
|
||||
bind:value={query}
|
||||
placeholder={$i18n.t('Search Projects')}
|
||||
placeholder={$i18n.t('Search Knowledge')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button
|
||||
class=" px-2 py-2 rounded-xl border border-gray-200 dark:border-gray-600 dark:border-0 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 transition font-medium text-sm flex items-center space-x-1"
|
||||
aria-label={$i18n.t('Create Project')}
|
||||
aria-label={$i18n.t('Create Knowledge')}
|
||||
on:click={() => {
|
||||
goto('/workspace/projects/create');
|
||||
goto('/workspace/knowledge/create');
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
@@ -114,25 +114,25 @@
|
||||
<hr class=" border-gray-50 dark:border-gray-850 my-2.5" />
|
||||
|
||||
<div class="my-3 mb-5 grid lg:grid-cols-2 xl:grid-cols-3 gap-2">
|
||||
{#each filteredProjects as project}
|
||||
{#each filteredItems as item}
|
||||
<button
|
||||
class=" flex space-x-4 cursor-pointer text-left w-full px-4 py-3 border border-gray-50 dark:border-gray-850 hover:bg-gray-50 dark:hover:bg-gray-850 rounded-xl"
|
||||
on:click={() => {
|
||||
if (project?.meta?.document) {
|
||||
toast.error($i18n.t('Documents cannot be edited, please create a new project.'));
|
||||
if (item?.meta?.document) {
|
||||
toast.error($i18n.t('Only collections can be edited, create a new knowledge instead.'));
|
||||
} else {
|
||||
goto(`/workspace/projects/${project.id}`);
|
||||
goto(`/workspace/knowledge/${item.id}`);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class=" w-full">
|
||||
<div class="flex items-center justify-between -mt-1">
|
||||
<div class=" font-semibold line-clamp-1 h-fit">{project.name}</div>
|
||||
<div class=" font-semibold line-clamp-1 h-fit">{item.name}</div>
|
||||
|
||||
<div class=" flex self-center">
|
||||
<ProjectMenu
|
||||
<ItemMenu
|
||||
on:delete={() => {
|
||||
selectedProject = project;
|
||||
selectedItem = item;
|
||||
showDeleteConfirm = true;
|
||||
}}
|
||||
/>
|
||||
@@ -141,12 +141,12 @@
|
||||
|
||||
<div class=" self-center flex-1">
|
||||
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
||||
{project.description}
|
||||
{item.description}
|
||||
</div>
|
||||
|
||||
<div class="mt-5 flex justify-between">
|
||||
<div>
|
||||
{#if project?.meta?.document}
|
||||
{#if item?.meta?.document}
|
||||
<div
|
||||
class="bg-gray-500/20 text-gray-700 dark:text-gray-200 rounded uppercase text-xs font-bold px-1"
|
||||
>
|
||||
@@ -156,12 +156,12 @@
|
||||
<div
|
||||
class="bg-green-500/20 text-green-700 dark:text-green-200 rounded uppercase text-xs font-bold px-1"
|
||||
>
|
||||
{$i18n.t('Project')}
|
||||
{$i18n.t('Collection')}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class=" text-xs text-gray-500">
|
||||
Updated {dayjs(project.updated_at * 1000).fromNow()}
|
||||
Updated {dayjs(item.updated_at * 1000).fromNow()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -171,5 +171,5 @@
|
||||
</div>
|
||||
|
||||
<div class=" text-gray-500 text-xs mt-1 mb-2">
|
||||
ⓘ {$i18n.t("Use '#' in the prompt input to load and select your projects.")}
|
||||
ⓘ {$i18n.t("Use '#' in the prompt input to load and include your knowledge.")}
|
||||
</div>
|
||||
@@ -3,9 +3,9 @@
|
||||
import { getContext } from 'svelte';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
import { createNewProject, getProjects } from '$lib/apis/projects';
|
||||
import { createNewKnowledge, getKnowledgeItems } from '$lib/apis/knowledge';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { projects } from '$lib/stores';
|
||||
import { knowledge } from '$lib/stores';
|
||||
|
||||
let loading = false;
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
const submitHandler = async () => {
|
||||
loading = true;
|
||||
|
||||
const res = await createNewProject(localStorage.token, name, description).catch((e) => {
|
||||
const res = await createNewKnowledge(localStorage.token, name, description).catch((e) => {
|
||||
toast.error(e);
|
||||
});
|
||||
|
||||
if (res) {
|
||||
toast.success($i18n.t('Project created successfully.'));
|
||||
projects.set(await getProjects(localStorage.token));
|
||||
goto(`/workspace/projects/${res.id}`);
|
||||
toast.success($i18n.t('Knowledge created successfully.'));
|
||||
knowledge.set(await getKnowledgeItems(localStorage.token));
|
||||
goto(`/workspace/knowledge/${res.id}`);
|
||||
}
|
||||
|
||||
loading = false;
|
||||
@@ -33,7 +33,7 @@
|
||||
<button
|
||||
class="flex space-x-1"
|
||||
on:click={() => {
|
||||
goto('/workspace/projects');
|
||||
goto('/workspace/knowledge');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center">
|
||||
@@ -60,7 +60,7 @@
|
||||
}}
|
||||
>
|
||||
<div class=" w-full flex flex-col justify-center">
|
||||
<div class=" text-2xl font-medium font-primary mb-2.5">Create a project</div>
|
||||
<div class=" text-2xl font-medium font-primary mb-2.5">Create a knowledge base</div>
|
||||
|
||||
<div class="w-full flex flex-col gap-2.5">
|
||||
<div class="w-full">
|
||||
@@ -71,7 +71,7 @@
|
||||
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
|
||||
type="text"
|
||||
bind:value={name}
|
||||
placeholder={`Name your project`}
|
||||
placeholder={`Name your knowledge base`}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
@@ -85,7 +85,7 @@
|
||||
class="w-full resize-none rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
|
||||
rows="4"
|
||||
bind:value={description}
|
||||
placeholder={`Describe your project, its goals, and objectives`}
|
||||
placeholder={`Describe your knowledge base and objectives`}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
@@ -102,7 +102,7 @@
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
>
|
||||
<div class=" self-center font-medium">{$i18n.t('Create Project')}</div>
|
||||
<div class=" self-center font-medium">{$i18n.t('Create Knowledge')}</div>
|
||||
|
||||
{#if loading}
|
||||
<div class="ml-1.5 self-center">
|
||||
68
src/lib/components/workspace/Knowledge/Item.svelte
Normal file
68
src/lib/components/workspace/Knowledge/Item.svelte
Normal file
@@ -0,0 +1,68 @@
|
||||
<script lang="ts">
|
||||
import { onMount, getContext } from 'svelte';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { getKnowledgeById } from '$lib/apis/knowledge';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
|
||||
let id = null;
|
||||
let knowledge = null;
|
||||
|
||||
onMount(async () => {
|
||||
id = $page.params.id;
|
||||
|
||||
const res = await getKnowledgeById(localStorage.token, id).catch((e) => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
if (res) {
|
||||
knowledge = res;
|
||||
} else {
|
||||
goto('/workspace/knowledge');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="w-full max-h-full">
|
||||
<button
|
||||
class="flex space-x-1"
|
||||
on:click={() => {
|
||||
goto('/workspace/knowledge');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
class="w-4 h-4"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M17 10a.75.75 0 01-.75.75H5.612l4.158 3.96a.75.75 0 11-1.04 1.08l-5.5-5.25a.75.75 0 010-1.08l5.5-5.25a.75.75 0 111.04 1.08L5.612 9.25H16.25A.75.75 0 0117 10z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
|
||||
</button>
|
||||
|
||||
<div class="flex flex-col my-2">
|
||||
{#if id && knowledge}
|
||||
<div>
|
||||
<div>
|
||||
<div class=" font-medium text-xl font-primary">
|
||||
{knowledge.name}
|
||||
</div>
|
||||
<div class=" line-clamp-2 font-medium text-sm">
|
||||
{knowledge.description}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<Spinner />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -3,33 +3,33 @@
|
||||
import { onMount, getContext } from 'svelte';
|
||||
import { flyAndScale } from '$lib/utils/transitions';
|
||||
|
||||
import { projects } from '$lib/stores';
|
||||
import { knowledge } from '$lib/stores';
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let onClose: Function = () => {};
|
||||
|
||||
export let knowledge = [];
|
||||
export let _knowledge = [];
|
||||
|
||||
let items = [];
|
||||
|
||||
onMount(() => {
|
||||
let collections = [
|
||||
...$projects
|
||||
...$knowledge
|
||||
.reduce((a, e, i, arr) => {
|
||||
return [...new Set([...a, ...(e?.content?.tags ?? []).map((tag) => tag.name)])];
|
||||
}, [])
|
||||
.map((tag) => ({
|
||||
name: tag,
|
||||
type: 'collection',
|
||||
collection_names: $projects
|
||||
collection_names: $knowledge
|
||||
.filter((doc) => (doc?.content?.tags ?? []).map((tag) => tag.name).includes(tag))
|
||||
.map((doc) => doc.collection_name)
|
||||
}))
|
||||
];
|
||||
|
||||
items = [...collections, ...$projects];
|
||||
items = [...collections, ...$knowledge];
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -60,9 +60,9 @@
|
||||
<DropdownMenu.Item
|
||||
class="flex gap-2.5 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
|
||||
on:click={() => {
|
||||
if (!knowledge.find((k) => k.name === item.name)) {
|
||||
knowledge = [
|
||||
...knowledge,
|
||||
if (!_knowledge.find((k) => k.name === item.name)) {
|
||||
_knowledge = [
|
||||
..._knowledge,
|
||||
{
|
||||
...item,
|
||||
type: item?.type ?? 'doc'
|
||||
|
||||
@@ -29,7 +29,7 @@ export const tags = writable([]);
|
||||
|
||||
export const models: Writable<Model[]> = writable([]);
|
||||
export const prompts: Writable<Prompt[]> = writable([]);
|
||||
export const projects: Writable<Document[]> = writable([]);
|
||||
export const knowledge: Writable<Document[]> = writable([]);
|
||||
|
||||
export const tools = writable([]);
|
||||
export const functions = writable([]);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import { page } from '$app/stores';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
import { getProjects } from '$lib/apis/projects';
|
||||
import { getKnowledgeItems } from '$lib/apis/knowledge';
|
||||
import { getFunctions } from '$lib/apis/functions';
|
||||
import { getModels as _getModels, getVersionUpdates } from '$lib/apis';
|
||||
import { getAllChatTags } from '$lib/apis/chats';
|
||||
@@ -28,7 +28,7 @@
|
||||
settings,
|
||||
models,
|
||||
prompts,
|
||||
projects,
|
||||
knowledge,
|
||||
tools,
|
||||
functions,
|
||||
tags,
|
||||
@@ -105,7 +105,7 @@
|
||||
prompts.set(await getPrompts(localStorage.token));
|
||||
})(),
|
||||
(async () => {
|
||||
projects.set(await getProjects(localStorage.token));
|
||||
knowledge.set(await getKnowledgeItems(localStorage.token));
|
||||
})(),
|
||||
(async () => {
|
||||
tools.set(await getTools(localStorage.token));
|
||||
|
||||
@@ -61,6 +61,17 @@
|
||||
href="/workspace/models">{$i18n.t('Models')}</a
|
||||
>
|
||||
|
||||
<a
|
||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes(
|
||||
'/workspace/knowledge'
|
||||
)
|
||||
? 'bg-gray-50 dark:bg-gray-850'
|
||||
: ''} transition"
|
||||
href="/workspace/knowledge"
|
||||
>
|
||||
{$i18n.t('Knowledge')}
|
||||
</a>
|
||||
|
||||
<a
|
||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/prompts')
|
||||
? 'bg-gray-50 dark:bg-gray-850'
|
||||
@@ -68,15 +79,6 @@
|
||||
href="/workspace/prompts">{$i18n.t('Prompts')}</a
|
||||
>
|
||||
|
||||
<a
|
||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/projects')
|
||||
? 'bg-gray-50 dark:bg-gray-850'
|
||||
: ''} transition"
|
||||
href="/workspace/projects"
|
||||
>
|
||||
{$i18n.t('Projects')}
|
||||
</a>
|
||||
|
||||
<a
|
||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/tools')
|
||||
? 'bg-gray-50 dark:bg-gray-850'
|
||||
|
||||
5
src/routes/(app)/workspace/knowledge/+page.svelte
Normal file
5
src/routes/(app)/workspace/knowledge/+page.svelte
Normal file
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import Knowledge from '$lib/components/workspace/Knowledge.svelte';
|
||||
</script>
|
||||
|
||||
<Knowledge />
|
||||
5
src/routes/(app)/workspace/knowledge/[id]/+page.svelte
Normal file
5
src/routes/(app)/workspace/knowledge/[id]/+page.svelte
Normal file
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import Knowledge from '$lib/components/workspace/Knowledge/Item.svelte';
|
||||
</script>
|
||||
|
||||
<Knowledge />
|
||||
5
src/routes/(app)/workspace/knowledge/create/+page.svelte
Normal file
5
src/routes/(app)/workspace/knowledge/create/+page.svelte
Normal file
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import CreateKnowledge from '$lib/components/workspace/Knowledge/CreateKnowledge.svelte';
|
||||
</script>
|
||||
|
||||
<CreateKnowledge />
|
||||
@@ -1,5 +0,0 @@
|
||||
<script>
|
||||
import Projects from '$lib/components/workspace/Projects.svelte';
|
||||
</script>
|
||||
|
||||
<Projects />
|
||||
@@ -1,7 +0,0 @@
|
||||
<script>
|
||||
import { page } from '$app/stores';
|
||||
|
||||
import Project from '$lib/components/workspace/Projects/Project.svelte';
|
||||
</script>
|
||||
|
||||
<Project />
|
||||
@@ -1,5 +0,0 @@
|
||||
<script>
|
||||
import CreateProject from '$lib/components/workspace/Projects/CreateProject.svelte';
|
||||
</script>
|
||||
|
||||
<CreateProject />
|
||||
Reference in New Issue
Block a user