Spaces:
Sleeping
Sleeping
Thomas G. Lopes
commited on
Commit
·
f5e7fbe
1
Parent(s):
693ced9
fix icon provider lag
Browse files
src/lib/components/DebugMenu.svelte
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
import { dev } from "$app/environment";
|
|
|
|
| 3 |
import { createPopover } from "@melt-ui/svelte";
|
| 4 |
|
| 5 |
let innerWidth: number;
|
| 6 |
let innerHeight: number;
|
| 7 |
-
let isDarkMode: boolean;
|
| 8 |
|
| 9 |
function toggleTheme() {
|
| 10 |
document.body.classList.toggle("dark");
|
|
@@ -43,6 +43,14 @@
|
|
| 43 |
>
|
| 44 |
Toggle Theme
|
| 45 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</div>
|
| 47 |
</div>
|
| 48 |
</div>
|
|
@@ -52,4 +60,3 @@
|
|
| 52 |
<style>
|
| 53 |
/* Add any additional styles here */
|
| 54 |
</style>
|
| 55 |
-
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
import { dev } from "$app/environment";
|
| 3 |
+
import { session } from "$lib/stores/session";
|
| 4 |
import { createPopover } from "@melt-ui/svelte";
|
| 5 |
|
| 6 |
let innerWidth: number;
|
| 7 |
let innerHeight: number;
|
|
|
|
| 8 |
|
| 9 |
function toggleTheme() {
|
| 10 |
document.body.classList.toggle("dark");
|
|
|
|
| 43 |
>
|
| 44 |
Toggle Theme
|
| 45 |
</button>
|
| 46 |
+
<button
|
| 47 |
+
class="rounded-md bg-gray-200 px-3 py-1 text-sm hover:bg-gray-300 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600"
|
| 48 |
+
on:click={() => {
|
| 49 |
+
console.log($session);
|
| 50 |
+
}}
|
| 51 |
+
>
|
| 52 |
+
Log session to console
|
| 53 |
+
</button>
|
| 54 |
</div>
|
| 55 |
</div>
|
| 56 |
</div>
|
|
|
|
| 60 |
<style>
|
| 61 |
/* Add any additional styles here */
|
| 62 |
</style>
|
|
|
src/lib/components/Icons/IconProvider.svelte
CHANGED
|
@@ -27,6 +27,8 @@
|
|
| 27 |
'<svg class="text-lg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 26 26"><rect x="3.34856" y="3.02654" width="19.9474" height="19.9474" rx="2.95009" fill="#FFD21E" stroke="#FFB41E" stroke-width="1.18004"></rect><path fill-rule="evenodd" clip-rule="evenodd" d="M7.69336 9.74609V16.9754H9.32329V13.9595H11.8181V16.9754H13.4591V9.74609H11.8181V12.5292H9.32329V9.74609H7.69336ZM15.1646 9.74609V16.9754H16.7945V14.1702H19.3004V12.7953H16.7945V11.121H19.7217V9.74609H15.1646Z" fill="#814D00"></path></svg>',
|
| 28 |
};
|
| 29 |
|
|
|
|
|
|
|
| 30 |
$: icon = provider && provider in icons ? icons[provider as keyof typeof icons] : null;
|
| 31 |
</script>
|
| 32 |
|
|
|
|
| 27 |
'<svg class="text-lg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 26 26"><rect x="3.34856" y="3.02654" width="19.9474" height="19.9474" rx="2.95009" fill="#FFD21E" stroke="#FFB41E" stroke-width="1.18004"></rect><path fill-rule="evenodd" clip-rule="evenodd" d="M7.69336 9.74609V16.9754H9.32329V13.9595H11.8181V16.9754H13.4591V9.74609H11.8181V12.5292H9.32329V9.74609H7.69336ZM15.1646 9.74609V16.9754H16.7945V14.1702H19.3004V12.7953H16.7945V11.121H19.7217V9.74609H15.1646Z" fill="#814D00"></path></svg>',
|
| 28 |
};
|
| 29 |
|
| 30 |
+
$: console.log("IconProvider", provider);
|
| 31 |
+
|
| 32 |
$: icon = provider && provider in icons ? icons[provider as keyof typeof icons] : null;
|
| 33 |
</script>
|
| 34 |
|
src/lib/components/InferencePlayground/InferencePlaygroundProviderSelect.svelte
CHANGED
|
@@ -6,12 +6,15 @@
|
|
| 6 |
import { createSelect, createSync } from "@melt-ui/svelte";
|
| 7 |
import IconCaret from "../Icons/IconCaret.svelte";
|
| 8 |
import IconProvider from "../Icons/IconProvider.svelte";
|
|
|
|
|
|
|
| 9 |
|
| 10 |
export let conversation: Conversation;
|
| 11 |
let classes: string | undefined = undefined;
|
| 12 |
export { classes as class };
|
| 13 |
|
| 14 |
function reset(providers: typeof conversation.model.inferenceProviderMapping) {
|
|
|
|
| 15 |
const validProvider = providers.find(p => p.provider === conversation.provider);
|
| 16 |
if (validProvider) return;
|
| 17 |
conversation.provider = randomPick(providers)?.provider;
|
|
@@ -62,6 +65,8 @@
|
|
| 62 |
|
| 63 |
return words.join(" ");
|
| 64 |
}
|
|
|
|
|
|
|
| 65 |
</script>
|
| 66 |
|
| 67 |
<div class="flex flex-col gap-2">
|
|
@@ -80,9 +85,11 @@
|
|
| 80 |
classes
|
| 81 |
)}
|
| 82 |
>
|
| 83 |
-
<div class="flex items-center gap-1 text-sm
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
| 86 |
</div>
|
| 87 |
<IconCaret classNames="text-xl bg-gray-100 dark:bg-gray-600 rounded-sm size-4 flex-none absolute right-2" />
|
| 88 |
</button>
|
|
|
|
| 6 |
import { createSelect, createSync } from "@melt-ui/svelte";
|
| 7 |
import IconCaret from "../Icons/IconCaret.svelte";
|
| 8 |
import IconProvider from "../Icons/IconProvider.svelte";
|
| 9 |
+
import { isMounted } from "$lib/stores/mounted";
|
| 10 |
+
import { browser } from "$app/environment";
|
| 11 |
|
| 12 |
export let conversation: Conversation;
|
| 13 |
let classes: string | undefined = undefined;
|
| 14 |
export { classes as class };
|
| 15 |
|
| 16 |
function reset(providers: typeof conversation.model.inferenceProviderMapping) {
|
| 17 |
+
if (!browser) return;
|
| 18 |
const validProvider = providers.find(p => p.provider === conversation.provider);
|
| 19 |
if (validProvider) return;
|
| 20 |
conversation.provider = randomPick(providers)?.provider;
|
|
|
|
| 65 |
|
| 66 |
return words.join(" ");
|
| 67 |
}
|
| 68 |
+
|
| 69 |
+
const mounted = isMounted();
|
| 70 |
</script>
|
| 71 |
|
| 72 |
<div class="flex flex-col gap-2">
|
|
|
|
| 85 |
classes
|
| 86 |
)}
|
| 87 |
>
|
| 88 |
+
<div class="flex items-center gap-1 text-sm">
|
| 89 |
+
{#key $mounted}
|
| 90 |
+
<IconProvider provider={conversation.provider} />
|
| 91 |
+
{formatName(conversation.provider ?? "") ?? "loading"}
|
| 92 |
+
{/key}
|
| 93 |
</div>
|
| 94 |
<IconCaret classNames="text-xl bg-gray-100 dark:bg-gray-600 rounded-sm size-4 flex-none absolute right-2" />
|
| 95 |
</button>
|
src/lib/stores/mounted.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { onMount } from "svelte";
|
| 2 |
+
import { readonly, writable } from "svelte/store";
|
| 3 |
+
|
| 4 |
+
export function isMounted() {
|
| 5 |
+
const store = writable(false);
|
| 6 |
+
onMount(() => store.set(true));
|
| 7 |
+
|
| 8 |
+
return readonly(store);
|
| 9 |
+
}
|
src/routes/+layout.svelte
CHANGED
|
@@ -5,4 +5,3 @@
|
|
| 5 |
|
| 6 |
<slot />
|
| 7 |
<DebugMenu />
|
| 8 |
-
|
|
|
|
| 5 |
|
| 6 |
<slot />
|
| 7 |
<DebugMenu />
|
|
|