token modal followup
Browse files
src/lib/components/Playground/Playground.svelte
CHANGED
@@ -145,7 +145,15 @@
|
|
145 |
<svelte:window on:keydown={onKeydown} />
|
146 |
|
147 |
{#if showTokenModal}
|
148 |
-
<PlaygroundTokenModal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
{/if}
|
150 |
|
151 |
<div
|
@@ -203,7 +211,7 @@
|
|
203 |
>Reset</button
|
204 |
>
|
205 |
<div class="flex-1 items-center justify-center text-center text-sm text-gray-500">
|
206 |
-
0 tokens · Latency {latency}ms
|
207 |
</div>
|
208 |
<button
|
209 |
type="button"
|
@@ -224,8 +232,10 @@
|
|
224 |
{!viewCode ? 'View Code' : 'Hide Code'}</button
|
225 |
>
|
226 |
<button
|
227 |
-
on:click={
|
228 |
-
|
|
|
|
|
229 |
type="button"
|
230 |
class="flex h-[42px] w-24 items-center justify-center rounded-lg bg-black px-5 py-2.5 text-sm font-medium text-white hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 disabled:opacity-50 dark:border-gray-700 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-gray-700"
|
231 |
>
|
|
|
145 |
<svelte:window on:keydown={onKeydown} />
|
146 |
|
147 |
{#if showTokenModal}
|
148 |
+
<PlaygroundTokenModal
|
149 |
+
on:close={() => (showTokenModal = false)}
|
150 |
+
on:submit={(e) => {
|
151 |
+
const formData = new FormData(e.target);
|
152 |
+
hfToken = formData.get('hf-token');
|
153 |
+
submit();
|
154 |
+
showTokenModal = false;
|
155 |
+
}}
|
156 |
+
/>
|
157 |
{/if}
|
158 |
|
159 |
<div
|
|
|
211 |
>Reset</button
|
212 |
>
|
213 |
<div class="flex-1 items-center justify-center text-center text-sm text-gray-500">
|
214 |
+
<span class="max-xl:hidden">0 tokens · Latency {latency}ms</span>
|
215 |
</div>
|
216 |
<button
|
217 |
type="button"
|
|
|
232 |
{!viewCode ? 'View Code' : 'Hide Code'}</button
|
233 |
>
|
234 |
<button
|
235 |
+
on:click={() => {
|
236 |
+
viewCode = false;
|
237 |
+
submit();
|
238 |
+
}}
|
239 |
type="button"
|
240 |
class="flex h-[42px] w-24 items-center justify-center rounded-lg bg-black px-5 py-2.5 text-sm font-medium text-white hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 disabled:opacity-50 dark:border-gray-700 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-gray-700"
|
241 |
>
|
src/lib/components/Playground/PlaygroundCode.svelte
CHANGED
@@ -62,13 +62,14 @@ for await (const chunk of hf.chatCompletionStream({
|
|
62 |
<h2 class="font-semibold">Install and instantiate</h2>
|
63 |
</div>
|
64 |
<pre
|
65 |
-
class="overflow-x-auto border-y border-
|
66 |
|
67 |
<div class="px-4 pb-4 pt-6">
|
68 |
<h2 class="font-semibold">{streaming ? 'Streaming API' : 'Non-Streaming API'}</h2>
|
69 |
</div>
|
70 |
|
71 |
-
<pre
|
|
|
72 |
? streamingSnippet
|
73 |
: nonStreamingSnippet}
|
74 |
</pre>
|
|
|
62 |
<h2 class="font-semibold">Install and instantiate</h2>
|
63 |
</div>
|
64 |
<pre
|
65 |
+
class="overflow-x-auto border-y border-gray-100 bg-gray-50 px-4 py-6 text-sm dark:border-gray-800 dark:bg-gray-800/50">{npmSnippet}</pre>
|
66 |
|
67 |
<div class="px-4 pb-4 pt-6">
|
68 |
<h2 class="font-semibold">{streaming ? 'Streaming API' : 'Non-Streaming API'}</h2>
|
69 |
</div>
|
70 |
|
71 |
+
<pre
|
72 |
+
class="overflow-x-auto border-y border-gray-100 bg-gray-50 px-4 py-6 text-sm dark:border-gray-800 dark:bg-gray-800/50">{streaming
|
73 |
? streamingSnippet
|
74 |
: nonStreamingSnippet}
|
75 |
</pre>
|
src/lib/components/Playground/PlaygroundTokenModal.svelte
CHANGED
@@ -42,7 +42,6 @@
|
|
42 |
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
43 |
<div
|
44 |
id="default-modal"
|
45 |
-
tabindex="-1"
|
46 |
aria-hidden="true"
|
47 |
class="fixed inset-0 z-50 flex items-center justify-center overflow-hidden bg-black/85"
|
48 |
bind:this={backdropEl}
|
@@ -51,11 +50,11 @@
|
|
51 |
<div
|
52 |
role="dialog"
|
53 |
tabindex="-1"
|
54 |
-
class="relative max-h-full w-full max-w-xl p-4"
|
55 |
bind:this={modalEl}
|
56 |
on:keydown={handleKeydown}
|
57 |
>
|
58 |
-
<
|
59 |
<div
|
60 |
class="flex items-center justify-between rounded-t border-b p-4 md:p-5 dark:border-gray-600"
|
61 |
>
|
@@ -68,7 +67,7 @@
|
|
68 |
class="ms-auto inline-flex h-8 w-8 items-center justify-center rounded-lg bg-transparent text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white"
|
69 |
>
|
70 |
<svg
|
71 |
-
class="
|
72 |
aria-hidden="true"
|
73 |
xmlns="http://www.w3.org/2000/svg"
|
74 |
fill="none"
|
@@ -93,14 +92,15 @@
|
|
93 |
><br /> Your token is kept safe by only being used from your browser.
|
94 |
</p>
|
95 |
<div class="mb-6">
|
96 |
-
<label
|
97 |
-
for="default-input"
|
98 |
-
class="mb-2 block text-sm font-medium text-gray-900 dark:text-white"
|
99 |
>Hugging Face Token</label
|
100 |
>
|
101 |
<input
|
|
|
|
|
102 |
type="text"
|
103 |
-
id="
|
|
|
104 |
class="block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500"
|
105 |
/>
|
106 |
</div>
|
@@ -119,11 +119,11 @@
|
|
119 |
>
|
120 |
|
121 |
<button
|
122 |
-
type="
|
123 |
class="mb-2 me-2 rounded-lg bg-black px-5 py-2.5 text-sm font-medium text-white hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700"
|
124 |
>Submit</button
|
125 |
>
|
126 |
</div>
|
127 |
-
</
|
128 |
</div>
|
129 |
</div>
|
|
|
42 |
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
43 |
<div
|
44 |
id="default-modal"
|
|
|
45 |
aria-hidden="true"
|
46 |
class="fixed inset-0 z-50 flex items-center justify-center overflow-hidden bg-black/85"
|
47 |
bind:this={backdropEl}
|
|
|
50 |
<div
|
51 |
role="dialog"
|
52 |
tabindex="-1"
|
53 |
+
class="relative max-h-full w-full max-w-xl p-4 outline-none"
|
54 |
bind:this={modalEl}
|
55 |
on:keydown={handleKeydown}
|
56 |
>
|
57 |
+
<form on:submit|preventDefault class="relative rounded-lg bg-white shadow dark:bg-gray-900">
|
58 |
<div
|
59 |
class="flex items-center justify-between rounded-t border-b p-4 md:p-5 dark:border-gray-600"
|
60 |
>
|
|
|
67 |
class="ms-auto inline-flex h-8 w-8 items-center justify-center rounded-lg bg-transparent text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white"
|
68 |
>
|
69 |
<svg
|
70 |
+
class="size-3"
|
71 |
aria-hidden="true"
|
72 |
xmlns="http://www.w3.org/2000/svg"
|
73 |
fill="none"
|
|
|
92 |
><br /> Your token is kept safe by only being used from your browser.
|
93 |
</p>
|
94 |
<div class="mb-6">
|
95 |
+
<label for="hf-token" class="mb-2 block text-sm font-medium text-gray-900 dark:text-white"
|
|
|
|
|
96 |
>Hugging Face Token</label
|
97 |
>
|
98 |
<input
|
99 |
+
required
|
100 |
+
placeholder="Enter HF Token"
|
101 |
type="text"
|
102 |
+
id="hf-token"
|
103 |
+
name="hf-token"
|
104 |
class="block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500"
|
105 |
/>
|
106 |
</div>
|
|
|
119 |
>
|
120 |
|
121 |
<button
|
122 |
+
type="submit"
|
123 |
class="mb-2 me-2 rounded-lg bg-black px-5 py-2.5 text-sm font-medium text-white hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700"
|
124 |
>Submit</button
|
125 |
>
|
126 |
</div>
|
127 |
+
</form>
|
128 |
</div>
|
129 |
</div>
|