diff --git a/src/lib/components/chat/ChatWindow.svelte b/src/lib/components/chat/ChatWindow.svelte index 65f3cbf20f2..c85f6dbaa9d 100644 --- a/src/lib/components/chat/ChatWindow.svelte +++ b/src/lib/components/chat/ChatWindow.svelte @@ -206,13 +206,14 @@ const settings = useSettingsStore(); // active tools are all the checked tools, either from settings or on by default - $: activeTools = $page.data.tools.filter((tool: ToolFront) => - $settings?.tools?.includes(tool._id) - ); + $: activeTools = $page.data.tools.filter((tool: ToolFront) => { + if ($page.data?.assistant) { + return $page.data.assistant.tools?.includes(tool._id); + } + return $settings?.tools?.includes(tool._id) ?? tool.isOnByDefault; + }); $: activeMimeTypes = [ - ...(!$page.data?.assistant && currentModel.tools - ? activeTools.flatMap((tool: ToolFront) => tool.mimeTypes ?? []) - : []), + ...(currentModel.tools ? activeTools.flatMap((tool: ToolFront) => tool.mimeTypes ?? []) : []), ...(currentModel.multimodal ? currentModel.multimodalAcceptedMimetypes ?? ["image/*"] : []), ]; diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 913dc9dc37b..5ce048cd0a3 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -46,13 +46,9 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => { const assistantActive = !models.map(({ id }) => id).includes(settings?.activeModel ?? ""); const assistant = assistantActive - ? JSON.parse( - JSON.stringify( - await collections.assistants.findOne({ - _id: new ObjectId(settings?.activeModel), - }) - ) - ) + ? await collections.assistants.findOne({ + _id: new ObjectId(settings?.activeModel), + }) : null; const conversations = await collections.conversations @@ -112,10 +108,14 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => { const configToolIds = toolFromConfigs.map((el) => el._id.toString()); - const activeCommunityToolIds = (settings?.tools ?? []).filter( + let activeCommunityToolIds = (settings?.tools ?? []).filter( (key) => !configToolIds.includes(key) ); + if (assistant) { + activeCommunityToolIds = [...activeCommunityToolIds, ...(assistant.tools ?? [])]; + } + const communityTools = await collections.tools .find({ _id: { $in: activeCommunityToolIds.map((el) => new ObjectId(el)) } }) .toArray() @@ -240,7 +240,7 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => { isAdmin: locals.user.isAdmin ?? false, isEarlyAccess: locals.user.isEarlyAccess ?? false, }, - assistant, + assistant: assistant ? JSON.parse(JSON.stringify(assistant)) : null, enableAssistants, enableAssistantsRAG: env.ENABLE_ASSISTANTS_RAG === "true", enableCommunityTools: env.COMMUNITY_TOOLS === "true",