Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
"stop" btn for streaming messages
Browse files
src/lib/components/InferencePlayground/InferencePlayground.svelte
CHANGED
|
@@ -85,7 +85,6 @@
|
|
| 85 |
}
|
| 86 |
(document.activeElement as HTMLElement).blur();
|
| 87 |
loading = true;
|
| 88 |
-
let streamingMsgAdded = false;
|
| 89 |
|
| 90 |
try {
|
| 91 |
const startTime = performance.now();
|
|
@@ -94,7 +93,6 @@
|
|
| 94 |
if (conversation.streaming) {
|
| 95 |
const streamingMessage = { role: "assistant", content: "" };
|
| 96 |
conversation.messages = [...conversation.messages, streamingMessage];
|
| 97 |
-
streamingMsgAdded = true;
|
| 98 |
abortController = new AbortController();
|
| 99 |
|
| 100 |
await handleStreamingResponse(
|
|
@@ -125,9 +123,6 @@
|
|
| 125 |
const endTime = performance.now();
|
| 126 |
latency = Math.round(endTime - startTime);
|
| 127 |
} catch (error) {
|
| 128 |
-
if (streamingMsgAdded) {
|
| 129 |
-
conversation.messages = conversation.messages.slice(0, -1);
|
| 130 |
-
}
|
| 131 |
if (error instanceof Error) {
|
| 132 |
if (error.message.includes("token seems invalid")) {
|
| 133 |
hfToken = "";
|
|
@@ -209,7 +204,9 @@
|
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
<div class="relative divide-y divide-gray-200 dark:divide-gray-800" on:keydown={onKeydown}>
|
| 212 |
-
<div
|
|
|
|
|
|
|
| 213 |
<Conversation
|
| 214 |
{loading}
|
| 215 |
{conversation}
|
|
@@ -288,7 +285,13 @@
|
|
| 288 |
>
|
| 289 |
{#if loading}
|
| 290 |
<div class="flex flex-none items-center gap-[3px]">
|
| 291 |
-
<span class="mr-2">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
<div
|
| 293 |
class="h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-100"
|
| 294 |
style="animation-delay: 0.25s;"
|
|
|
|
| 85 |
}
|
| 86 |
(document.activeElement as HTMLElement).blur();
|
| 87 |
loading = true;
|
|
|
|
| 88 |
|
| 89 |
try {
|
| 90 |
const startTime = performance.now();
|
|
|
|
| 93 |
if (conversation.streaming) {
|
| 94 |
const streamingMessage = { role: "assistant", content: "" };
|
| 95 |
conversation.messages = [...conversation.messages, streamingMessage];
|
|
|
|
| 96 |
abortController = new AbortController();
|
| 97 |
|
| 98 |
await handleStreamingResponse(
|
|
|
|
| 123 |
const endTime = performance.now();
|
| 124 |
latency = Math.round(endTime - startTime);
|
| 125 |
} catch (error) {
|
|
|
|
|
|
|
|
|
|
| 126 |
if (error instanceof Error) {
|
| 127 |
if (error.message.includes("token seems invalid")) {
|
| 128 |
hfToken = "";
|
|
|
|
| 204 |
</div>
|
| 205 |
</div>
|
| 206 |
<div class="relative divide-y divide-gray-200 dark:divide-gray-800" on:keydown={onKeydown}>
|
| 207 |
+
<div
|
| 208 |
+
class="flex h-[calc(100dvh-5rem-120px)] divide-x divide-gray-200 pt-3 *:w-full md:h-[calc(100dvh-5rem)] dark:divide-gray-800"
|
| 209 |
+
>
|
| 210 |
<Conversation
|
| 211 |
{loading}
|
| 212 |
{conversation}
|
|
|
|
| 285 |
>
|
| 286 |
{#if loading}
|
| 287 |
<div class="flex flex-none items-center gap-[3px]">
|
| 288 |
+
<span class="mr-2">
|
| 289 |
+
{#if conversation.streaming}
|
| 290 |
+
Stop
|
| 291 |
+
{:else}
|
| 292 |
+
Cancel
|
| 293 |
+
{/if}
|
| 294 |
+
</span>
|
| 295 |
<div
|
| 296 |
class="h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-100"
|
| 297 |
style="animation-delay: 0.25s;"
|
src/lib/components/InferencePlayground/InferencePlaygroundMessage.svelte
CHANGED
|
@@ -27,7 +27,7 @@
|
|
| 27 |
dispatch("delete");
|
| 28 |
}}
|
| 29 |
type="button"
|
| 30 |
-
class="mt-1.5
|
| 31 |
>✕</button
|
| 32 |
>
|
| 33 |
</div>
|
|
|
|
| 27 |
dispatch("delete");
|
| 28 |
}}
|
| 29 |
type="button"
|
| 30 |
+
class="mt-1.5 size-8 rounded-lg border border-gray-200 bg-white text-xs 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 group-hover/message:block sm:hidden 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"
|
| 31 |
>✕</button
|
| 32 |
>
|
| 33 |
</div>
|