Skip to content

Commit

Permalink
fix: show file upload button when assistant has tool with file support (
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin authored Oct 18, 2024
1 parent bafdc73 commit 767edda
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/lib/components/chat/ChatWindow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"] : []),
];
Expand Down
18 changes: 9 additions & 9 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 767edda

Please sign in to comment.