Spaces:
Sleeping
Sleeping
feat: add warnings to let people know they should use a tool calling model (#1590)
Browse files
src/routes/tools/+page.svelte
CHANGED
@@ -20,6 +20,7 @@
|
|
20 |
import { SortKey } from "$lib/types/Assistant";
|
21 |
import ToolLogo from "$lib/components/ToolLogo.svelte";
|
22 |
import { ReviewStatus } from "$lib/types/Review";
|
|
|
23 |
|
24 |
export let data: PageData;
|
25 |
|
@@ -31,6 +32,11 @@
|
|
31 |
$: createdByMe = data.user?.username && data.user.username === toolsCreator;
|
32 |
$: activeOnly = $page.url.searchParams.get("active") === "true";
|
33 |
|
|
|
|
|
|
|
|
|
|
|
34 |
const SEARCH_DEBOUNCE_DELAY = 400;
|
35 |
let filterInputEl: HTMLInputElement;
|
36 |
let filterValue = data.query;
|
@@ -144,7 +150,7 @@
|
|
144 |
</a>
|
145 |
</div>
|
146 |
|
147 |
-
<div class="mt-7 flex flex-wrap items-center gap-x-2 gap-y-3 text-sm">
|
148 |
{#if toolsCreator && !createdByMe}
|
149 |
<div
|
150 |
class="flex items-center gap-1.5 rounded-full border border-gray-300 bg-gray-50 px-3 py-1 dark:border-gray-600 dark:bg-gray-700 dark:text-white"
|
@@ -231,7 +237,14 @@
|
|
231 |
</select>
|
232 |
</div>
|
233 |
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
{#each tools as tool}
|
236 |
{@const isActive = ($page.data.settings?.tools ?? []).includes(tool._id.toString())}
|
237 |
{@const isOfficial = !tool.createdByName}
|
|
|
20 |
import { SortKey } from "$lib/types/Assistant";
|
21 |
import ToolLogo from "$lib/components/ToolLogo.svelte";
|
22 |
import { ReviewStatus } from "$lib/types/Review";
|
23 |
+
import { useSettingsStore } from "$lib/stores/settings";
|
24 |
|
25 |
export let data: PageData;
|
26 |
|
|
|
32 |
$: createdByMe = data.user?.username && data.user.username === toolsCreator;
|
33 |
$: activeOnly = $page.url.searchParams.get("active") === "true";
|
34 |
|
35 |
+
const settings = useSettingsStore();
|
36 |
+
|
37 |
+
$: currentModelSupportTools =
|
38 |
+
data.models.find((m) => m.id === $settings.activeModel)?.tools ?? false;
|
39 |
+
|
40 |
const SEARCH_DEBOUNCE_DELAY = 400;
|
41 |
let filterInputEl: HTMLInputElement;
|
42 |
let filterValue = data.query;
|
|
|
150 |
</a>
|
151 |
</div>
|
152 |
|
153 |
+
<div class="mb-4 mt-7 flex flex-wrap items-center gap-x-2 gap-y-3 text-sm">
|
154 |
{#if toolsCreator && !createdByMe}
|
155 |
<div
|
156 |
class="flex items-center gap-1.5 rounded-full border border-gray-300 bg-gray-50 px-3 py-1 dark:border-gray-600 dark:bg-gray-700 dark:text-white"
|
|
|
237 |
</select>
|
238 |
</div>
|
239 |
|
240 |
+
{#if !currentModelSupportTools}
|
241 |
+
<div class="mx-auto text-center text-sm text-purple-700 dark:text-purple-300">
|
242 |
+
You are currently not using a model that supports tools. Activate one
|
243 |
+
<a href="{base}/models" class="underline">here</a>.
|
244 |
+
</div>
|
245 |
+
{/if}
|
246 |
+
|
247 |
+
<div class="mt-4 grid grid-cols-1 gap-3 sm:gap-5 lg:grid-cols-2">
|
248 |
{#each tools as tool}
|
249 |
{@const isActive = ($page.data.settings?.tools ?? []).includes(tool._id.toString())}
|
250 |
{@const isOfficial = !tool.createdByName}
|
src/routes/tools/[toolId]/+page.svelte
CHANGED
@@ -39,6 +39,9 @@
|
|
39 |
$: isActive = $settings.tools?.includes(data.tool?._id.toString());
|
40 |
|
41 |
let displayReportModal = false;
|
|
|
|
|
|
|
42 |
</script>
|
43 |
|
44 |
{#if displayReportModal}
|
@@ -98,25 +101,34 @@
|
|
98 |
class="flex flex-wrap items-center gap-x-4 gap-y-2 whitespace-nowrap text-sm text-gray-500 hover:*:text-gray-800 max-sm:justify-center"
|
99 |
>
|
100 |
<div class="w-full sm:w-auto">
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
</div>
|
121 |
{#if data.tool?.createdByMe}
|
122 |
<a href="{base}/tools/{data.tool?._id}/edit" class="underline"
|
@@ -242,9 +254,16 @@
|
|
242 |
</div>
|
243 |
</div>
|
244 |
</div>
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
{#if data.tool.description}
|
249 |
<div>
|
250 |
<h2 class="text-lg font-semibold">Description</h2>
|
|
|
39 |
$: isActive = $settings.tools?.includes(data.tool?._id.toString());
|
40 |
|
41 |
let displayReportModal = false;
|
42 |
+
|
43 |
+
$: currentModelSupportTools =
|
44 |
+
data.models.find((m) => m.id === $settings.activeModel)?.tools ?? false;
|
45 |
</script>
|
46 |
|
47 |
{#if displayReportModal}
|
|
|
101 |
class="flex flex-wrap items-center gap-x-4 gap-y-2 whitespace-nowrap text-sm text-gray-500 hover:*:text-gray-800 max-sm:justify-center"
|
102 |
>
|
103 |
<div class="w-full sm:w-auto">
|
104 |
+
{#if currentModelSupportTools}
|
105 |
+
<button
|
106 |
+
class="{isActive
|
107 |
+
? 'bg-gray-100 text-gray-800'
|
108 |
+
: 'bg-black !text-white'} mx-auto my-2 flex w-min items-center justify-center rounded-full px-3 py-1 text-base"
|
109 |
+
name="Activate model"
|
110 |
+
on:click|stopPropagation={() => {
|
111 |
+
if (isActive) {
|
112 |
+
settings.instantSet({
|
113 |
+
tools: ($settings?.tools ?? []).filter((t) => t !== data.tool._id),
|
114 |
+
});
|
115 |
+
} else {
|
116 |
+
settings.instantSet({
|
117 |
+
tools: [...($settings?.tools ?? []), data.tool._id],
|
118 |
+
});
|
119 |
+
}
|
120 |
+
}}
|
121 |
+
>
|
122 |
+
{isActive ? "Deactivate" : "Activate"}
|
123 |
+
</button>
|
124 |
+
{:else}
|
125 |
+
<button
|
126 |
+
disabled
|
127 |
+
class="mx-auto my-2 flex w-min items-center justify-center rounded-full bg-gray-200 px-3 py-1 text-base text-gray-500"
|
128 |
+
>
|
129 |
+
Activate
|
130 |
+
</button>
|
131 |
+
{/if}
|
132 |
</div>
|
133 |
{#if data.tool?.createdByMe}
|
134 |
<a href="{base}/tools/{data.tool?._id}/edit" class="underline"
|
|
|
254 |
</div>
|
255 |
</div>
|
256 |
</div>
|
257 |
+
{#if !currentModelSupportTools}
|
258 |
+
<span class="relative text-sm text-gray-500">
|
259 |
+
You are currently not using a model that supports tools. Activate one
|
260 |
+
<a href="{base}/models" class="underline">here</a>.
|
261 |
+
</span>
|
262 |
+
{:else}
|
263 |
+
<p class="text-sm max-sm:hidden">
|
264 |
+
Tools are applications that the model can choose to call while you are chatting with it.
|
265 |
+
</p>
|
266 |
+
{/if}
|
267 |
{#if data.tool.description}
|
268 |
<div>
|
269 |
<h2 class="text-lg font-semibold">Description</h2>
|