Spaces:
Running
Running
Add start chat button on models & assistants. (#963)
Browse files* Add start chat on models & assistants
* bg bit darker for vis
* show "New Chat" button regardless of active
---------
Co-authored-by: Victor Mustar <[email protected]>
src/routes/settings/(nav)/[...model]/+page.svelte
CHANGED
@@ -8,6 +8,9 @@
|
|
8 |
import TokensCounter from "$lib/components/TokensCounter.svelte";
|
9 |
import CarbonArrowUpRight from "~icons/carbon/arrow-up-right";
|
10 |
import CarbonLink from "~icons/carbon/link";
|
|
|
|
|
|
|
11 |
|
12 |
const settings = useSettingsStore();
|
13 |
|
@@ -23,8 +26,6 @@
|
|
23 |
$settings.customPrompts[$page.params.model] !==
|
24 |
$page.data.models.find((el: BackendModel) => el.id === $page.params.model)?.preprompt;
|
25 |
|
26 |
-
$: isActive = $settings.activeModel === $page.params.model;
|
27 |
-
|
28 |
$: model = $page.data.models.find((el: BackendModel) => el.id === $page.params.model);
|
29 |
</script>
|
30 |
|
@@ -88,16 +89,17 @@
|
|
88 |
</div>
|
89 |
|
90 |
<button
|
91 |
-
class="
|
92 |
-
? 'bg-gray-100'
|
93 |
-
: 'bg-black text-white'} my-8 flex items-center rounded-full px-3 py-1"
|
94 |
-
disabled={isActive}
|
95 |
name="Activate model"
|
96 |
on:click|stopPropagation={() => {
|
97 |
-
|
|
|
|
|
|
|
98 |
}}
|
99 |
>
|
100 |
-
|
|
|
101 |
</button>
|
102 |
|
103 |
<div class="relative flex w-full flex-col gap-2">
|
|
|
8 |
import TokensCounter from "$lib/components/TokensCounter.svelte";
|
9 |
import CarbonArrowUpRight from "~icons/carbon/arrow-up-right";
|
10 |
import CarbonLink from "~icons/carbon/link";
|
11 |
+
import CarbonChat from "~icons/carbon/chat";
|
12 |
+
|
13 |
+
import { goto } from "$app/navigation";
|
14 |
|
15 |
const settings = useSettingsStore();
|
16 |
|
|
|
26 |
$settings.customPrompts[$page.params.model] !==
|
27 |
$page.data.models.find((el: BackendModel) => el.id === $page.params.model)?.preprompt;
|
28 |
|
|
|
|
|
29 |
$: model = $page.data.models.find((el: BackendModel) => el.id === $page.params.model);
|
30 |
</script>
|
31 |
|
|
|
89 |
</div>
|
90 |
|
91 |
<button
|
92 |
+
class="my-2 flex w-fit items-center rounded-full bg-black px-3 py-1 text-base !text-white"
|
|
|
|
|
|
|
93 |
name="Activate model"
|
94 |
on:click|stopPropagation={() => {
|
95 |
+
settings.instantSet({
|
96 |
+
activeModel: $page.params.model,
|
97 |
+
});
|
98 |
+
goto(`${base}/`);
|
99 |
}}
|
100 |
>
|
101 |
+
<CarbonChat class="mr-1.5 text-sm" />
|
102 |
+
New chat
|
103 |
</button>
|
104 |
|
105 |
<div class="relative flex w-full flex-col gap-2">
|
src/routes/settings/(nav)/assistants/[assistantId]/+page.svelte
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
import { enhance } from "$app/forms";
|
3 |
import { base } from "$app/paths";
|
4 |
import { page } from "$app/stores";
|
|
|
5 |
import { env as envPublic } from "$env/dynamic/public";
|
6 |
import { useSettingsStore } from "$lib/stores/settings";
|
7 |
import type { PageData } from "./$types";
|
@@ -11,8 +12,10 @@
|
|
11 |
import CarbonCopy from "~icons/carbon/copy-file";
|
12 |
import CarbonFlag from "~icons/carbon/flag";
|
13 |
import CarbonLink from "~icons/carbon/link";
|
|
|
14 |
import CarbonStar from "~icons/carbon/star";
|
15 |
import CarbonTools from "~icons/carbon/tools";
|
|
|
16 |
import CopyToClipBoardBtn from "$lib/components/CopyToClipBoardBtn.svelte";
|
17 |
import ReportModal from "./ReportModal.svelte";
|
18 |
import IconInternet from "$lib/components/icons/IconInternet.svelte";
|
@@ -24,8 +27,6 @@
|
|
24 |
|
25 |
const settings = useSettingsStore();
|
26 |
|
27 |
-
$: isActive = $settings.activeModel === $page.params.assistantId;
|
28 |
-
|
29 |
const prefix =
|
30 |
envPublic.PUBLIC_SHARE_PREFIX || `${envPublic.PUBLIC_ORIGIN || $page.url.origin}${base}`;
|
31 |
|
@@ -98,16 +99,17 @@
|
|
98 |
class="flex items-center gap-4 whitespace-nowrap text-sm text-gray-500 hover:*:text-gray-800"
|
99 |
>
|
100 |
<button
|
101 |
-
class="
|
102 |
-
? 'bg-gray-100 text-gray-800'
|
103 |
-
: 'bg-black !text-white'} my-2 flex w-fit items-center rounded-full px-3 py-1 text-base"
|
104 |
-
disabled={isActive}
|
105 |
name="Activate model"
|
106 |
on:click|stopPropagation={() => {
|
107 |
-
|
|
|
|
|
|
|
108 |
}}
|
109 |
>
|
110 |
-
|
|
|
111 |
</button>
|
112 |
{#if assistant?.createdByMe}
|
113 |
<a href="{base}/settings/assistants/{assistant?._id}/edit" class="underline"
|
|
|
2 |
import { enhance } from "$app/forms";
|
3 |
import { base } from "$app/paths";
|
4 |
import { page } from "$app/stores";
|
5 |
+
import { goto } from "$app/navigation";
|
6 |
import { env as envPublic } from "$env/dynamic/public";
|
7 |
import { useSettingsStore } from "$lib/stores/settings";
|
8 |
import type { PageData } from "./$types";
|
|
|
12 |
import CarbonCopy from "~icons/carbon/copy-file";
|
13 |
import CarbonFlag from "~icons/carbon/flag";
|
14 |
import CarbonLink from "~icons/carbon/link";
|
15 |
+
import CarbonChat from "~icons/carbon/chat";
|
16 |
import CarbonStar from "~icons/carbon/star";
|
17 |
import CarbonTools from "~icons/carbon/tools";
|
18 |
+
|
19 |
import CopyToClipBoardBtn from "$lib/components/CopyToClipBoardBtn.svelte";
|
20 |
import ReportModal from "./ReportModal.svelte";
|
21 |
import IconInternet from "$lib/components/icons/IconInternet.svelte";
|
|
|
27 |
|
28 |
const settings = useSettingsStore();
|
29 |
|
|
|
|
|
30 |
const prefix =
|
31 |
envPublic.PUBLIC_SHARE_PREFIX || `${envPublic.PUBLIC_ORIGIN || $page.url.origin}${base}`;
|
32 |
|
|
|
99 |
class="flex items-center gap-4 whitespace-nowrap text-sm text-gray-500 hover:*:text-gray-800"
|
100 |
>
|
101 |
<button
|
102 |
+
class="my-2 flex w-fit items-center rounded-full bg-black px-3 py-1 text-base !text-white"
|
|
|
|
|
|
|
103 |
name="Activate model"
|
104 |
on:click|stopPropagation={() => {
|
105 |
+
settings.instantSet({
|
106 |
+
activeModel: $page.params.assistantId,
|
107 |
+
});
|
108 |
+
goto(`${base}/`);
|
109 |
}}
|
110 |
>
|
111 |
+
<CarbonChat class="mr-1.5 text-sm" />
|
112 |
+
New chat
|
113 |
</button>
|
114 |
{#if assistant?.createdByMe}
|
115 |
<a href="{base}/settings/assistants/{assistant?._id}/edit" class="underline"
|