Spaces:
Running
Running
feat: add overloaded model modal for huggingchat
Browse files
src/lib/components/OverloadedModal.svelte
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { goto } from "$app/navigation";
|
3 |
+
import { base } from "$app/paths";
|
4 |
+
import { page } from "$app/state";
|
5 |
+
import IconDazzled from "./icons/IconDazzled.svelte";
|
6 |
+
import Modal from "./Modal.svelte";
|
7 |
+
|
8 |
+
let { onClose }: { onClose: () => void } = $props();
|
9 |
+
</script>
|
10 |
+
|
11 |
+
<Modal on:close={onClose}>
|
12 |
+
<div
|
13 |
+
class="from-primary-500/40 via-primary-500/10 to-primary-500/0 flex w-full flex-col items-center gap-3 bg-gradient-to-b px-5 pb-4 pt-9 text-center sm:px-6"
|
14 |
+
>
|
15 |
+
<div class="flex flex-wrap items-center gap-2">
|
16 |
+
<IconDazzled classNames="text-3xl mx-auto" />
|
17 |
+
<h2 class="flex flex-wrap items-center text-lg font-semibold text-gray-800">
|
18 |
+
This model is currently overloaded.
|
19 |
+
</h2>
|
20 |
+
</div>
|
21 |
+
|
22 |
+
<p class="text-sm text-gray-500">
|
23 |
+
Please try again later or consider using a different model. We currently have {page.data
|
24 |
+
.models.length} models available.
|
25 |
+
</p>
|
26 |
+
|
27 |
+
<div class="flex w-full flex-col items-center gap-4 pt-4">
|
28 |
+
<button
|
29 |
+
onclick={() => (onClose(), goto(`${base}/models`))}
|
30 |
+
class="flex w-full flex-wrap items-center justify-center whitespace-nowrap rounded-full border-2 border-black bg-black px-5 py-2 text-lg font-semibold text-gray-100 transition-colors hover:bg-gray-900"
|
31 |
+
>
|
32 |
+
See all available models
|
33 |
+
</button>
|
34 |
+
<button
|
35 |
+
onclick={onClose}
|
36 |
+
class="flex w-fit flex-wrap items-center justify-center whitespace-nowrap px-2 py-1 text-gray-600 transition-colors hover:text-gray-900"
|
37 |
+
>
|
38 |
+
Close
|
39 |
+
</button>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
</Modal>
|
src/routes/+layout.svelte
CHANGED
@@ -23,6 +23,8 @@
|
|
23 |
import ExpandNavigation from "$lib/components/ExpandNavigation.svelte";
|
24 |
import { loginModalOpen } from "$lib/stores/loginModal";
|
25 |
import LoginModal from "$lib/components/LoginModal.svelte";
|
|
|
|
|
26 |
|
27 |
let { data = $bindable(), children } = $props();
|
28 |
|
@@ -34,6 +36,8 @@
|
|
34 |
let isNavOpen = $state(false);
|
35 |
let isNavCollapsed = $state(false);
|
36 |
|
|
|
|
|
37 |
let errorToastTimeout: ReturnType<typeof setTimeout>;
|
38 |
let currentError: string | undefined = $state();
|
39 |
|
@@ -47,6 +51,9 @@
|
|
47 |
|
48 |
currentError = $error;
|
49 |
|
|
|
|
|
|
|
50 |
errorToastTimeout = setTimeout(() => {
|
51 |
$error = undefined;
|
52 |
currentError = undefined;
|
@@ -235,6 +242,10 @@
|
|
235 |
/>
|
236 |
{/if}
|
237 |
|
|
|
|
|
|
|
|
|
238 |
<div
|
239 |
class="fixed grid h-full w-screen grid-cols-1 grid-rows-[auto,1fr] overflow-hidden text-smd {!isNavCollapsed
|
240 |
? 'md:grid-cols-[290px,1fr]'
|
|
|
23 |
import ExpandNavigation from "$lib/components/ExpandNavigation.svelte";
|
24 |
import { loginModalOpen } from "$lib/stores/loginModal";
|
25 |
import LoginModal from "$lib/components/LoginModal.svelte";
|
26 |
+
import OverloadedModal from "$lib/components/OverloadedModal.svelte";
|
27 |
+
import { isHuggingChat } from "$lib/utils/isHuggingChat";
|
28 |
|
29 |
let { data = $bindable(), children } = $props();
|
30 |
|
|
|
36 |
let isNavOpen = $state(false);
|
37 |
let isNavCollapsed = $state(false);
|
38 |
|
39 |
+
let overloadedModalOpen = $state(false);
|
40 |
+
|
41 |
let errorToastTimeout: ReturnType<typeof setTimeout>;
|
42 |
let currentError: string | undefined = $state();
|
43 |
|
|
|
51 |
|
52 |
currentError = $error;
|
53 |
|
54 |
+
if (currentError === "Model is overloaded") {
|
55 |
+
overloadedModalOpen = true;
|
56 |
+
}
|
57 |
errorToastTimeout = setTimeout(() => {
|
58 |
$error = undefined;
|
59 |
currentError = undefined;
|
|
|
242 |
/>
|
243 |
{/if}
|
244 |
|
245 |
+
{#if overloadedModalOpen && isHuggingChat}
|
246 |
+
<OverloadedModal onClose={() => (overloadedModalOpen = false)} />
|
247 |
+
{/if}
|
248 |
+
|
249 |
<div
|
250 |
class="fixed grid h-full w-screen grid-cols-1 grid-rows-[auto,1fr] overflow-hidden text-smd {!isNavCollapsed
|
251 |
? 'md:grid-cols-[290px,1fr]'
|