Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Thomas G. Lopes
commited on
Commit
·
9281a4f
1
Parent(s):
0df1a9e
re-run when last msg is user's
Browse files
src/lib/components/inference-playground/message-textarea.svelte
CHANGED
@@ -44,7 +44,18 @@
|
|
44 |
}
|
45 |
|
46 |
async function sendMessage() {
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
localToasts.addToast({
|
49 |
data: {
|
50 |
content: "Please enter a message",
|
@@ -54,8 +65,7 @@
|
|
54 |
return;
|
55 |
}
|
56 |
|
57 |
-
|
58 |
-
|
59 |
let images: string[] | undefined;
|
60 |
if (canUploadImgs) {
|
61 |
images = await uploadImages();
|
|
|
44 |
}
|
45 |
|
46 |
async function sendMessage() {
|
47 |
+
const c = conversations.active;
|
48 |
+
const hasEmptyInput = input.trim() === "" && fileUpload.selected.size === 0;
|
49 |
+
const lastMessageIsUser = c.some(conv => conv.data.messages?.at(-1)?.role === "user");
|
50 |
+
|
51 |
+
// If input is empty and last message is user, just re-run the conversation
|
52 |
+
if (hasEmptyInput && lastMessageIsUser) {
|
53 |
+
conversations.genNextMessages();
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
// If input is empty but last message is not user, show warning
|
58 |
+
if (hasEmptyInput) {
|
59 |
localToasts.addToast({
|
60 |
data: {
|
61 |
content: "Please enter a message",
|
|
|
65 |
return;
|
66 |
}
|
67 |
|
68 |
+
// Normal flow: add user message and generate response
|
|
|
69 |
let images: string[] | undefined;
|
70 |
if (canUploadImgs) {
|
71 |
images = await uploadImages();
|