diff --git a/src/lib/helpers/types/agentTypes.js b/src/lib/helpers/types/agentTypes.js index 8e8c10e4..312b42e2 100644 --- a/src/lib/helpers/types/agentTypes.js +++ b/src/lib/helpers/types/agentTypes.js @@ -52,6 +52,7 @@ * @property {boolean} merge_utility - Merge utility * @property {number?} [max_message_count] * @property {AgentUtility[]} utilities - The agent utilities. + * @property {AgentKnowledgeBase[]} knowledge_bases - The agent knowledge bases. * @property {Date} created_datetime * @property {Date} updated_datetime * @property {AgentLlmConfig} llm_config - LLM settings. @@ -126,6 +127,12 @@ * @property {UtilityBase[]} templates */ +/** + * @typedef {Object} AgentKnowledgeBase + * @property {string} name + * @property {boolean} disabled + */ + /** * @typedef {Object} UtilityBase * @property {string} name diff --git a/src/routes/page/agent/[agentId]/+page.svelte b/src/routes/page/agent/[agentId]/+page.svelte index 3a8781a2..6ca89a71 100644 --- a/src/routes/page/agent/[agentId]/+page.svelte +++ b/src/routes/page/agent/[agentId]/+page.svelte @@ -19,6 +19,7 @@ import Swal from 'sweetalert2' import { goto } from '$app/navigation'; import AgentUtility from './agent-utility.svelte'; + import AgentKnowledgeBase from './agent-knowledge-base.svelte'; import { AgentExtensions } from '$lib/helpers/utils/agent'; @@ -30,6 +31,8 @@ let agentPromptCmp = null; /** @type {any} */ let agentUtilityCmp = null; + /** @type {any} */ + let agentKnowledgeBaseCmp = null; /** @type {boolean} */ let isLoading = false; @@ -70,6 +73,7 @@ fetchJsonContent(); fetchPrompts(); fetchUtilties(); + fetchKnowledgeBases(); agent = { ...agent, @@ -78,6 +82,7 @@ channel_instructions: agent.channel_instructions || [], profiles: agent.profiles?.filter((x, idx, self) => x?.trim()?.length > 0 && self.indexOf(x) === idx) || [], utilities: agent.utilities || [], + knowledge_bases: agent.knowledge_bases || [], max_message_count: Number(agent.max_message_count) > 0 ? Number(agent.max_message_count) : null }; isLoading = true; @@ -121,6 +126,11 @@ agent.utilities = list || []; } + function fetchKnowledgeBases() { + const list = agentKnowledgeBaseCmp?.fetchKnowledgeBases(); + agent.knowledge_bases = list || []; + } + function refreshChannelPrompts() { agentPromptCmp?.refreshChannelPrompts(); } @@ -167,6 +177,9 @@
+
+ +
diff --git a/src/routes/page/agent/[agentId]/agent-knowledge-base.svelte b/src/routes/page/agent/[agentId]/agent-knowledge-base.svelte new file mode 100644 index 00000000..e4c2a2f6 --- /dev/null +++ b/src/routes/page/agent/[agentId]/agent-knowledge-base.svelte @@ -0,0 +1,173 @@ + + + + +
+
Knowledge Bases
+
+ +
+ {#each innerKnowledgeBases as knowledge, uid (uid)} +
+
+
+
{`Collection #${uid + 1}`}
+
+
+ toggleKnowledgeBase(e, uid)} + /> +
+
+ +
+
+
+
+
+ changeKnowledgeBase(e, uid)} + > + {#each [...knowledgeBaseOptions, "one.data-assistant"] as option} + + {/each} + +
+
+ {}} + on:click={() => deleteKnowledgeBase(uid)} + /> +
+
+
+
+ {/each} + + {#if innerKnowledgeBases.length < limit} +
+ +
+ {/if} +
+
+
\ No newline at end of file