Spaces:
Running
Running
fix: show file upload button when assistant has tool with file support (#1532)
Browse files
src/lib/components/chat/ChatWindow.svelte
CHANGED
@@ -206,13 +206,14 @@
|
|
206 |
const settings = useSettingsStore();
|
207 |
|
208 |
// active tools are all the checked tools, either from settings or on by default
|
209 |
-
$: activeTools = $page.data.tools.filter((tool: ToolFront) =>
|
210 |
-
$
|
211 |
-
|
|
|
|
|
|
|
212 |
$: activeMimeTypes = [
|
213 |
-
...(
|
214 |
-
? activeTools.flatMap((tool: ToolFront) => tool.mimeTypes ?? [])
|
215 |
-
: []),
|
216 |
...(currentModel.multimodal ? currentModel.multimodalAcceptedMimetypes ?? ["image/*"] : []),
|
217 |
];
|
218 |
|
|
|
206 |
const settings = useSettingsStore();
|
207 |
|
208 |
// active tools are all the checked tools, either from settings or on by default
|
209 |
+
$: activeTools = $page.data.tools.filter((tool: ToolFront) => {
|
210 |
+
if ($page.data?.assistant) {
|
211 |
+
return $page.data.assistant.tools?.includes(tool._id);
|
212 |
+
}
|
213 |
+
return $settings?.tools?.includes(tool._id) ?? tool.isOnByDefault;
|
214 |
+
});
|
215 |
$: activeMimeTypes = [
|
216 |
+
...(currentModel.tools ? activeTools.flatMap((tool: ToolFront) => tool.mimeTypes ?? []) : []),
|
|
|
|
|
217 |
...(currentModel.multimodal ? currentModel.multimodalAcceptedMimetypes ?? ["image/*"] : []),
|
218 |
];
|
219 |
|
src/routes/+layout.server.ts
CHANGED
@@ -46,13 +46,9 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
|
|
46 |
const assistantActive = !models.map(({ id }) => id).includes(settings?.activeModel ?? "");
|
47 |
|
48 |
const assistant = assistantActive
|
49 |
-
?
|
50 |
-
|
51 |
-
|
52 |
-
_id: new ObjectId(settings?.activeModel),
|
53 |
-
})
|
54 |
-
)
|
55 |
-
)
|
56 |
: null;
|
57 |
|
58 |
const conversations = await collections.conversations
|
@@ -112,10 +108,14 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
|
|
112 |
|
113 |
const configToolIds = toolFromConfigs.map((el) => el._id.toString());
|
114 |
|
115 |
-
|
116 |
(key) => !configToolIds.includes(key)
|
117 |
);
|
118 |
|
|
|
|
|
|
|
|
|
119 |
const communityTools = await collections.tools
|
120 |
.find({ _id: { $in: activeCommunityToolIds.map((el) => new ObjectId(el)) } })
|
121 |
.toArray()
|
@@ -240,7 +240,7 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
|
|
240 |
isAdmin: locals.user.isAdmin ?? false,
|
241 |
isEarlyAccess: locals.user.isEarlyAccess ?? false,
|
242 |
},
|
243 |
-
assistant,
|
244 |
enableAssistants,
|
245 |
enableAssistantsRAG: env.ENABLE_ASSISTANTS_RAG === "true",
|
246 |
enableCommunityTools: env.COMMUNITY_TOOLS === "true",
|
|
|
46 |
const assistantActive = !models.map(({ id }) => id).includes(settings?.activeModel ?? "");
|
47 |
|
48 |
const assistant = assistantActive
|
49 |
+
? await collections.assistants.findOne({
|
50 |
+
_id: new ObjectId(settings?.activeModel),
|
51 |
+
})
|
|
|
|
|
|
|
|
|
52 |
: null;
|
53 |
|
54 |
const conversations = await collections.conversations
|
|
|
108 |
|
109 |
const configToolIds = toolFromConfigs.map((el) => el._id.toString());
|
110 |
|
111 |
+
let activeCommunityToolIds = (settings?.tools ?? []).filter(
|
112 |
(key) => !configToolIds.includes(key)
|
113 |
);
|
114 |
|
115 |
+
if (assistant) {
|
116 |
+
activeCommunityToolIds = [...activeCommunityToolIds, ...(assistant.tools ?? [])];
|
117 |
+
}
|
118 |
+
|
119 |
const communityTools = await collections.tools
|
120 |
.find({ _id: { $in: activeCommunityToolIds.map((el) => new ObjectId(el)) } })
|
121 |
.toArray()
|
|
|
240 |
isAdmin: locals.user.isAdmin ?? false,
|
241 |
isEarlyAccess: locals.user.isEarlyAccess ?? false,
|
242 |
},
|
243 |
+
assistant: assistant ? JSON.parse(JSON.stringify(assistant)) : null,
|
244 |
enableAssistants,
|
245 |
enableAssistantsRAG: env.ENABLE_ASSISTANTS_RAG === "true",
|
246 |
enableCommunityTools: env.COMMUNITY_TOOLS === "true",
|