Thomas G. Lopes commited on
Commit
a32010b
·
1 Parent(s): 73b132d

fix run button

Browse files
src/lib/components/inference-playground/message-textarea.svelte CHANGED
@@ -15,21 +15,25 @@
15
  const ctrlOrMeta = event.ctrlKey || event.metaKey;
16
 
17
  if (ctrlOrMeta && event.key === "Enter") {
18
- const c = conversations.active;
19
- const isValid = c.every(c => c.data.messages?.at(-1)?.role !== "user");
 
 
 
 
 
20
 
21
- if (!isValid) {
22
- addToast({
23
- title: "Cannot add message",
24
- description: "Cannot have multiple user messages in a row",
25
 
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
- }
33
  }
34
  }
35
 
@@ -51,7 +55,8 @@
51
  ></textarea>
52
  <button
53
  onclick={() => {
54
- conversations.genOrStop();
 
55
  }}
56
  type="button"
57
  class={[
 
15
  const ctrlOrMeta = event.ctrlKey || event.metaKey;
16
 
17
  if (ctrlOrMeta && event.key === "Enter") {
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");
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
  }
38
  }
39
 
 
55
  ></textarea>
56
  <button
57
  onclick={() => {
58
+ if (loading) conversations.stopGenerating();
59
+ else sendMessage();
60
  }}
61
  type="button"
62
  class={[