File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
src/lib/components/InferencePlayground Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 85
85
}
86
86
(document .activeElement as HTMLElement ).blur ();
87
87
loading = true ;
88
- let streamingMsgAdded = false ;
89
88
90
89
try {
91
90
const startTime = performance .now ();
94
93
if (conversation .streaming ) {
95
94
const streamingMessage = { role: " assistant" , content: " " };
96
95
conversation .messages = [... conversation .messages , streamingMessage ];
97
- streamingMsgAdded = true ;
98
96
abortController = new AbortController ();
99
97
100
98
await handleStreamingResponse (
125
123
const endTime = performance .now ();
126
124
latency = Math .round (endTime - startTime );
127
125
} catch (error ) {
128
- if (streamingMsgAdded ) {
129
- conversation .messages = conversation .messages .slice (0 , - 1 );
130
- }
131
126
if (error instanceof Error ) {
132
127
if (error .message .includes (" token seems invalid" )) {
133
128
hfToken = " " ;
209
204
</div >
210
205
</div >
211
206
<div class ="relative divide-y divide-gray-200 dark:divide-gray-800" on:keydown ={onKeydown }>
212
- <div class =" flex h-[calc(100dvh-5rem-120px)] md:h-[calc(100dvh-5rem)] divide-x divide-gray-200 *:w-full dark:divide-gray-800 pt-3" >
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
+ >
213
210
<Conversation
214
211
{loading }
215
212
{conversation }
288
285
>
289
286
{#if loading }
290
287
<div class =" flex flex-none items-center gap-[3px]" >
291
- <span class =" mr-2" >Cancel</span >
288
+ <span class =" mr-2" >
289
+ {#if conversation .streaming }
290
+ Stop
291
+ {:else }
292
+ Cancel
293
+ {/if }
294
+ </span >
292
295
<div
293
296
class =" h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-100"
294
297
style =" animation-delay: 0.25s;"
Original file line number Diff line number Diff line change 27
27
dispatch (" delete" );
28
28
}}
29
29
type =" button"
30
- class =" mt-1.5 sm:hidden 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 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"
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
31
>✕</button
32
32
>
33
33
</div >
You can’t perform that action at this time.
0 commit comments