File tree Expand file tree Collapse file tree 1 file changed +19
-14
lines changed
src/lib/components/inference-playground Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change 15
15
const ctrlOrMeta = event .ctrlKey || event .metaKey ;
16
16
17
17
if (ctrlOrMeta && event .key === " Enter" ) {
18
- const c = conversations .active ;
19
- const isValid = c .every (c => c .data .messages ?.at (- 1 )?.role !== " user" );
18
+ sendMessage ();
19
+ }
20
+ }
21
+
22
+ async function sendMessage() {
23
+ const c = conversations .active ;
24
+ const isValid = c .every (c => c .data .messages ?.at (- 1 )?.role !== " user" );
20
25
21
- if (! isValid ) {
22
- addToast ({
23
- title: " Cannot add message" ,
24
- description: " Cannot have multiple user messages in a row" ,
26
+ if (! isValid ) {
27
+ addToast ({
28
+ title: " Cannot add message" ,
29
+ description: " Cannot have multiple user messages in a row" ,
25
30
26
- variant: " error" ,
27
- });
28
- } else {
29
- await Promise .all (c .map (c => c .addMessage ({ role: " user" , content: input })));
30
- c .forEach (c => c .genNextMessage ());
31
- input = " " ;
32
- }
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 = " " ;
33
37
}
34
38
}
35
39
51
55
></textarea >
52
56
<button
53
57
onclick ={() => {
54
- conversations .genOrStop ();
58
+ if (loading ) conversations .stopGenerating ();
59
+ else sendMessage ();
55
60
}}
56
61
type =" button"
57
62
class ={[
You can’t perform that action at this time.
0 commit comments