File tree Expand file tree Collapse file tree 5 files changed +31
-39
lines changed
components/inference-playground Expand file tree Collapse file tree 5 files changed +31
-39
lines changed Original file line number Diff line number Diff line change 64
64
}
65
65
66
66
@utility btn {
67
- @apply flex h-[39px ] items-center justify-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:ring-4 focus:ring-gray-100 focus:outline-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;
67
+ @apply flex h-[39px ] items-center justify-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:ring-4 focus:ring-gray-100 focus:outline-hidden dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-600 dark:hover:text-white dark:focus:ring-gray-700;
68
68
}
69
69
70
70
@utility btn-sm {
71
- @apply flex h-[32px ] items-center justify-center gap-1.5 rounded-md border border-gray-200 bg-white px-2.5 py-2 text-xs font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:ring-4 focus:ring-gray-100 focus:outline-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;
71
+ @apply flex h-[32px ] items-center justify-center gap-1.5 rounded-md border border-gray-200 bg-white px-2.5 py-2 text-xs font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:ring-4 focus:ring-gray-100 focus:outline-hidden dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-600 dark:hover:text-white dark:focus:ring-gray-700;
72
72
}
73
73
74
74
@utility btn-xs {
75
- @apply flex h-[28px ] items-center justify-center gap-1 rounded border border-gray-200 bg-white px-2 py-1.5 text-xs font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:ring-4 focus:ring-gray-100 focus:outline-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;
75
+ @apply flex h-[28px ] items-center justify-center gap-1 rounded border border-gray-200 bg-white px-2 py-1.5 text-xs font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:ring-4 focus:ring-gray-100 focus:outline-hidden dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-600 dark:hover:text-white dark:focus:ring-gray-700;
76
76
}
77
77
78
78
@utility btn-mini {
79
- @apply flex h-[24px ] items-center justify-center gap-0.5 rounded-sm border border-gray-200 bg-white px-1.5 py-1 text-[10px ] font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:ring-2 focus:ring-gray-100 focus:outline-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;
79
+ @apply flex h-[24px ] items-center justify-center gap-0.5 rounded-sm border border-gray-200 bg-white px-1.5 py-1 text-[10px ] font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:ring-2 focus:ring-gray-100 focus:outline-hidden dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-600 dark:hover:text-white dark:focus:ring-gray-700;
80
80
}
81
81
82
82
@utility custom-outline {
Original file line number Diff line number Diff line change 57
57
bind:this ={messageContainer }
58
58
>
59
59
{#if ! viewCode }
60
- {#each conversation .data .messages || [] as message , index }
61
- <Message
62
- {message }
63
- {index }
64
- {conversation }
65
- onDelete ={() => conversation .deleteMessage (index )}
66
- onRegen ={() => regenMessage (index )}
67
- />
68
- {/each }
60
+ {#if conversation .data .messages ?.length }
61
+ {#each conversation .data .messages as message , index }
62
+ <Message
63
+ {message }
64
+ {index }
65
+ {conversation }
66
+ onDelete ={() => conversation .deleteMessage (index )}
67
+ onRegen ={() => regenMessage (index )}
68
+ />
69
+ {:else }
70
+ <div class =" m-auto flex flex-col items-center gap-2 text-center px-4 text-balance" >
71
+ <h1 class =" text-2xl font-semibold" >Welcome to Hugging Face Inference Playground</h1 >
72
+ <p class =" text-lg text-gray-500" >Try hundreds of models on different providers</p >
73
+ </div >
74
+ {/each }
75
+ {/if }
69
76
{:else }
70
77
<CodeSnippets {conversation } {onCloseCode } />
71
78
{/if }
Original file line number Diff line number Diff line change 21
21
22
22
async function sendMessage() {
23
23
const c = conversations .active ;
24
- const isValid = c .every (c => c .data .messages ?.at (- 1 )?.role !== " user" );
25
-
26
- if (! isValid ) {
27
- addToast ({
28
- title: " Cannot add message" ,
29
- description: " Cannot have multiple user messages in a row" ,
30
-
31
- variant: " error" ,
32
- });
33
- } else {
34
- await Promise .all (c .map (c => c .addMessage ({ role: " user" , content: input })));
35
- c .forEach (c => c .genNextMessage ());
36
- input = " " ;
37
- }
24
+ await Promise .all (c .map (c => c .addMessage ({ role: " user" , content: input })));
25
+ c .forEach (c => c .genNextMessage ());
26
+ input = " " ;
38
27
}
39
28
40
29
const autosized = new TextareaAutosize ();
41
30
</script >
42
31
43
32
<svelte:window onkeydown ={onKeydown } />
44
33
45
- <div class =" mt-auto p -2" >
34
+ <div class =" mt-auto px -2" >
46
35
<label
47
- class =" flex w-full items-end rounded-[32px] bg-gray-200 p-2 pl-8 outline-offset-2 outline-blue -500 focus-within:outline-2 dark:bg-gray-800"
36
+ class =" flex w-full items-end rounded-[32px] bg-gray-200 p-2 pl-6 outline-gray -500 focus-within:outline-2 dark:bg-gray-800"
48
37
>
49
38
<textarea
50
39
placeholder =" Enter your message"
Original file line number Diff line number Diff line change 119
119
120
120
<!-- Bottom bar -->
121
121
<div
122
- class =" relative mt-auto flex h-20 shrink-0 items-center justify-center gap-2 overflow-hidden border-t border-gray-200 px-3 whitespace-nowrap dark:border-gray-800 "
122
+ class =" relative mt-auto flex h-14 shrink-0 items-center justify-center gap-2 overflow-hidden px-3 whitespace-nowrap"
123
123
>
124
124
<div class =" flex flex-1 justify-start gap-x-2" >
125
125
{#if ! compareActive }
126
126
<button
127
127
type =" button"
128
128
onclick ={() => (viewSettings = ! viewSettings )}
129
- class =" flex h-[39px] items-center gap-1 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:ring-4 focus:ring-gray-100 focus:outline-hidden md: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"
129
+ class =" flex h-[28px]! px-2 items-center gap-1 rounded-lg border border-gray-200 bg-white py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 focus:outline-hidden md:hidden dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700"
130
130
>
131
- <div class =" text-black dark:text-white" >
132
- <IconSettings />
133
- </div >
131
+ <IconSettings />
134
132
{! viewSettings ? " Settings" : " Hide" }
135
133
</button >
136
134
{/if }
139
137
<button
140
138
type =" button"
141
139
onclick ={conversations .reset }
142
- class =" btn size-[39px] "
140
+ class =" btn size-[28px]! p-0! "
143
141
{...tooltip .trigger }
144
142
data-test-id ={TEST_IDS .reset }
145
143
>
170
168
<button
171
169
type =" button"
172
170
onclick ={() => (viewCode = ! viewCode )}
173
- class =" btn"
171
+ class =" btn h-[28px]! px-2! "
174
172
{@attach observe ({ name: ObservedElements .BottomActions , useRaf: true })}
175
173
>
176
174
<IconCode />
Original file line number Diff line number Diff line change @@ -57,8 +57,6 @@ export type ConversationEntityMembers = MembersOnly<ConversationEntity>;
57
57
58
58
const conversationsRepo = repo ( ConversationEntity , idb ) ;
59
59
60
- const startMessageUser : ConversationMessage = { role : "user" , content : "" } ;
61
-
62
60
export const emptyModel : Model = {
63
61
_id : "" ,
64
62
inferenceProviderMapping : [ ] ,
@@ -78,7 +76,7 @@ function getDefaultConversation(projectId: string) {
78
76
projectId,
79
77
modelId : models . trending [ 0 ] ?. id ?? models . remote [ 0 ] ?. id ?? emptyModel . id ,
80
78
config : { ...defaultGenerationConfig } ,
81
- messages : [ { ... startMessageUser } ] ,
79
+ messages : [ ] ,
82
80
streaming : true ,
83
81
createdAt : new Date ( ) ,
84
82
} satisfies Partial < ConversationEntityMembers > ;
You can’t perform that action at this time.
0 commit comments