Skip to content

Commit a32010b

Browse files
committed
fix run button
1 parent 73b132d commit a32010b

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/lib/components/inference-playground/message-textarea.svelte

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@
1515
const ctrlOrMeta = event.ctrlKey || event.metaKey;
1616
1717
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");
2025
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",
2530
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 = "";
3337
}
3438
}
3539
@@ -51,7 +55,8 @@
5155
></textarea>
5256
<button
5357
onclick={() => {
54-
conversations.genOrStop();
58+
if (loading) conversations.stopGenerating();
59+
else sendMessage();
5560
}}
5661
type="button"
5762
class={[

0 commit comments

Comments
 (0)