Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
ok
Browse files
src/app.css
CHANGED
|
@@ -1,3 +1,8 @@
|
|
| 1 |
@tailwind base;
|
| 2 |
@tailwind components;
|
| 3 |
@tailwind utilities;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
@tailwind base;
|
| 2 |
@tailwind components;
|
| 3 |
@tailwind utilities;
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
html {
|
| 7 |
+
font-size: 15px;
|
| 8 |
+
}
|
src/lib/components/Playground/Playground.svelte
CHANGED
|
@@ -7,10 +7,12 @@
|
|
| 7 |
import PlaygroundTokenModal from './PlaygroundTokenModal.svelte';
|
| 8 |
|
| 9 |
type Message = {
|
| 10 |
-
role:
|
| 11 |
content: string;
|
| 12 |
};
|
| 13 |
|
|
|
|
|
|
|
| 14 |
const compatibleModels: string[] = [
|
| 15 |
'01-ai/Yi-1.5-34B-Chat',
|
| 16 |
'codellama/CodeLlama-34b-Instruct-hf',
|
|
@@ -38,8 +40,8 @@
|
|
| 38 |
|
| 39 |
const startMessages: Message[] = [{ role: 'user', content: '' }];
|
| 40 |
|
|
|
|
| 41 |
let messages = startMessages;
|
| 42 |
-
let systemMessage = { role: 'system', content: '' };
|
| 43 |
let currentModel = compatibleModels[0];
|
| 44 |
let temperature = 0.5;
|
| 45 |
let maxTokens = 2048;
|
|
@@ -70,12 +72,6 @@
|
|
| 70 |
systemMessage.content = '';
|
| 71 |
}
|
| 72 |
|
| 73 |
-
function onKeydown(event: KeyboardEvent) {
|
| 74 |
-
if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') {
|
| 75 |
-
submit();
|
| 76 |
-
}
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
async function submit() {
|
| 80 |
if (!hfToken) {
|
| 81 |
showTokenModal = true;
|
|
@@ -88,11 +84,9 @@
|
|
| 88 |
try {
|
| 89 |
const hf = new HfInference(hfToken);
|
| 90 |
|
| 91 |
-
const requestMessages = [
|
| 92 |
-
...(systemMessage.content.length
|
| 93 |
-
|
| 94 |
-
: []),
|
| 95 |
-
...messages.map(({ role, content }) => ({ role, content }))
|
| 96 |
];
|
| 97 |
|
| 98 |
if (streaming) {
|
|
@@ -126,7 +120,8 @@
|
|
| 126 |
});
|
| 127 |
|
| 128 |
if (response.choices && response.choices.length > 0) {
|
| 129 |
-
|
|
|
|
| 130 |
messages = [...messages, newMessage];
|
| 131 |
scrollToBottom();
|
| 132 |
}
|
|
@@ -142,6 +137,12 @@
|
|
| 142 |
}
|
| 143 |
}
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
function scrollToBottom() {
|
| 146 |
if (messageContainer) {
|
| 147 |
messageContainer.scrollTop = messageContainer.scrollHeight;
|
|
@@ -202,14 +203,34 @@
|
|
| 202 |
>
|
| 203 |
<button
|
| 204 |
type="button"
|
| 205 |
-
class="flex-none rounded-lg border border-gray-200 bg-white px-
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
>
|
| 208 |
|
| 209 |
<button
|
| 210 |
type="button"
|
| 211 |
on:click={reset}
|
| 212 |
-
class="flex size-[
|
| 213 |
><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"
|
| 214 |
><path fill="currentColor" d="M12 12h2v12h-2zm6 0h2v12h-2z" /><path
|
| 215 |
fill="currentColor"
|
|
@@ -223,7 +244,7 @@
|
|
| 223 |
<button
|
| 224 |
type="button"
|
| 225 |
on:click={() => (viewCode = !viewCode)}
|
| 226 |
-
class="flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-
|
| 227 |
>
|
| 228 |
<svg
|
| 229 |
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -244,7 +265,7 @@
|
|
| 244 |
submit();
|
| 245 |
}}
|
| 246 |
type="button"
|
| 247 |
-
class="flex h-[
|
| 248 |
>
|
| 249 |
{#if loading}
|
| 250 |
<div class="flex flex-none items-center gap-[3px]">
|
|
|
|
| 7 |
import PlaygroundTokenModal from './PlaygroundTokenModal.svelte';
|
| 8 |
|
| 9 |
type Message = {
|
| 10 |
+
role: string;
|
| 11 |
content: string;
|
| 12 |
};
|
| 13 |
|
| 14 |
+
$: console.log(messages);
|
| 15 |
+
|
| 16 |
const compatibleModels: string[] = [
|
| 17 |
'01-ai/Yi-1.5-34B-Chat',
|
| 18 |
'codellama/CodeLlama-34b-Instruct-hf',
|
|
|
|
| 40 |
|
| 41 |
const startMessages: Message[] = [{ role: 'user', content: '' }];
|
| 42 |
|
| 43 |
+
let systemMessage: Message = { role: 'system', content: '' };
|
| 44 |
let messages = startMessages;
|
|
|
|
| 45 |
let currentModel = compatibleModels[0];
|
| 46 |
let temperature = 0.5;
|
| 47 |
let maxTokens = 2048;
|
|
|
|
| 72 |
systemMessage.content = '';
|
| 73 |
}
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
async function submit() {
|
| 76 |
if (!hfToken) {
|
| 77 |
showTokenModal = true;
|
|
|
|
| 84 |
try {
|
| 85 |
const hf = new HfInference(hfToken);
|
| 86 |
|
| 87 |
+
const requestMessages: Message[] = [
|
| 88 |
+
...(systemMessage.content.length ? [systemMessage] : []),
|
| 89 |
+
...messages
|
|
|
|
|
|
|
| 90 |
];
|
| 91 |
|
| 92 |
if (streaming) {
|
|
|
|
| 120 |
});
|
| 121 |
|
| 122 |
if (response.choices && response.choices.length > 0) {
|
| 123 |
+
console.log(response.choice);
|
| 124 |
+
const newMessage: Message = response.choices[0].message;
|
| 125 |
messages = [...messages, newMessage];
|
| 126 |
scrollToBottom();
|
| 127 |
}
|
|
|
|
| 137 |
}
|
| 138 |
}
|
| 139 |
|
| 140 |
+
function onKeydown(event: KeyboardEvent) {
|
| 141 |
+
if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') {
|
| 142 |
+
submit();
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
function scrollToBottom() {
|
| 147 |
if (messageContainer) {
|
| 148 |
messageContainer.scrollTop = messageContainer.scrollHeight;
|
|
|
|
| 203 |
>
|
| 204 |
<button
|
| 205 |
type="button"
|
| 206 |
+
class="flex h-[39px] flex-none gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700"
|
| 207 |
+
>
|
| 208 |
+
<div
|
| 209 |
+
class="flex size-5 items-center justify-center rounded border border-black/5 bg-black/5 text-xs"
|
| 210 |
+
>
|
| 211 |
+
<svg
|
| 212 |
+
width="1em"
|
| 213 |
+
height="1em"
|
| 214 |
+
viewBox="0 0 24 25"
|
| 215 |
+
fill="none"
|
| 216 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 217 |
+
>
|
| 218 |
+
<path
|
| 219 |
+
fill-rule="evenodd"
|
| 220 |
+
clip-rule="evenodd"
|
| 221 |
+
d="M5.41 9.41L4 8L12 0L20 8L18.59 9.41L13 3.83L13 17.5H11L11 3.83L5.41 9.41ZM22 17.5V23H2V17.5H0V23C0 23.5304 0.210714 24.0391 0.585786 24.4142C0.960859 24.7893 1.46957 25 2 25H22C22.5304 25 23.0391 24.7893 23.4142 24.4142C23.7893 24.0391 24 23.5304 24 23V17.5H22Z"
|
| 222 |
+
fill="currentColor"
|
| 223 |
+
/>
|
| 224 |
+
</svg>
|
| 225 |
+
</div>
|
| 226 |
+
|
| 227 |
+
Share</button
|
| 228 |
>
|
| 229 |
|
| 230 |
<button
|
| 231 |
type="button"
|
| 232 |
on:click={reset}
|
| 233 |
+
class="flex size-[39px] flex-none items-center justify-center rounded-lg border border-gray-200 bg-white text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700"
|
| 234 |
><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"
|
| 235 |
><path fill="currentColor" d="M12 12h2v12h-2zm6 0h2v12h-2z" /><path
|
| 236 |
fill="currentColor"
|
|
|
|
| 244 |
<button
|
| 245 |
type="button"
|
| 246 |
on:click={() => (viewCode = !viewCode)}
|
| 247 |
+
class="flex h-[39px] items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700"
|
| 248 |
>
|
| 249 |
<svg
|
| 250 |
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
| 265 |
submit();
|
| 266 |
}}
|
| 267 |
type="button"
|
| 268 |
+
class="flex h-[39px] w-24 items-center justify-center gap-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 disabled:opacity-50 dark:border-gray-700 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-gray-700"
|
| 269 |
>
|
| 270 |
{#if loading}
|
| 271 |
<div class="flex flex-none items-center gap-[3px]">
|
src/lib/components/Playground/PlaygroundTokenModal.svelte
CHANGED
|
@@ -56,10 +56,14 @@
|
|
| 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:
|
| 60 |
>
|
| 61 |
-
<h3 class="text-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
</h3>
|
| 64 |
<button
|
| 65 |
type="button"
|
|
|
|
| 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:px-5 md:py-4 dark:border-gray-600"
|
| 60 |
>
|
| 61 |
+
<h3 class="flex items-center gap-2.5 text-lg font-semibold text-gray-900 dark:text-white">
|
| 62 |
+
<img
|
| 63 |
+
alt="Hugging Face's logo"
|
| 64 |
+
class="w-7"
|
| 65 |
+
src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
|
| 66 |
+
/> Use a Hugging Face Token
|
| 67 |
</h3>
|
| 68 |
<button
|
| 69 |
type="button"
|