瀏覽代碼

only cancel chat completion if the deleted message is the most recently sent

Danny Liu 1 年之前
父節點
當前提交
a655ccdd06
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/lib/components/chat/Messages.svelte

+ 5 - 1
src/lib/components/chat/Messages.svelte

@@ -227,9 +227,13 @@
 		history.messages[messageId].deleted = true;
 		history.messages[messageId].deleted = true;
 		history.messages[history.messages[messageId].childrenIds[0]].deleted = true;
 		history.messages[history.messages[messageId].childrenIds[0]].deleted = true;
 
 
+		const responseId = history.messages[messageId].childrenIds[0];
+		if (history.messages[responseId].childrenIds.length === 0) {
+			await cancelChatCompletion(localStorage.token, chatId);
+		}
+
 		await updateChatById(localStorage.token, chatId, { history });
 		await updateChatById(localStorage.token, chatId, { history });
 		await chats.set(await getChatList(localStorage.token));
 		await chats.set(await getChatList(localStorage.token));
-		await cancelChatCompletion(localStorage.token, chatId);
 	};
 	};
 </script>
 </script>