Skip to content

Commit 836b733

Browse files
committed
feat: add overloaded model modal for huggingchat
1 parent 61db0cf commit 836b733

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import ExpandNavigation from "$lib/components/ExpandNavigation.svelte";
2424
import { loginModalOpen } from "$lib/stores/loginModal";
2525
import LoginModal from "$lib/components/LoginModal.svelte";
26+
import OverloadedModal from "$lib/components/OverloadedModal.svelte";
27+
import { isHuggingChat } from "$lib/utils/isHuggingChat";
2628
2729
let { data = $bindable(), children } = $props();
2830
@@ -34,6 +36,8 @@
3436
let isNavOpen = $state(false);
3537
let isNavCollapsed = $state(false);
3638
39+
let overloadedModalOpen = $state(false);
40+
3741
let errorToastTimeout: ReturnType<typeof setTimeout>;
3842
let currentError: string | undefined = $state();
3943
@@ -47,6 +51,9 @@
4751
4852
currentError = $error;
4953
54+
if (currentError === "Model is overloaded") {
55+
overloadedModalOpen = true;
56+
}
5057
errorToastTimeout = setTimeout(() => {
5158
$error = undefined;
5259
currentError = undefined;
@@ -235,6 +242,10 @@
235242
/>
236243
{/if}
237244

245+
{#if overloadedModalOpen && isHuggingChat}
246+
<OverloadedModal onClose={() => (overloadedModalOpen = false)} />
247+
{/if}
248+
238249
<div
239250
class="fixed grid h-full w-screen grid-cols-1 grid-rows-[auto,1fr] overflow-hidden text-smd {!isNavCollapsed
240251
? 'md:grid-cols-[290px,1fr]'

0 commit comments

Comments
 (0)