From fec51342ca381c3bc4746af12256f9fc41cb6642 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 30 May 2024 02:37:43 -0700 Subject: [PATCH] fix: filter outlet issue with many model chat --- src/lib/components/chat/Chat.svelte | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index bb0975445..e58d2cdc4 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -236,6 +236,15 @@ } }; + const createMessagesList = (responseMessageId) => { + const message = history.messages[responseMessageId]; + if (message.parentId) { + return [...createMessagesList(message.parentId), message]; + } else { + return [message]; + } + }; + ////////////////////////// // Ollama functions ////////////////////////// @@ -599,6 +608,7 @@ controller.abort('User: Stop Response'); await cancelOllamaRequest(localStorage.token, currentRequestId); } else { + const messages = createMessagesList(responseMessageId); const res = await chatCompleted(localStorage.token, { model: model, messages: messages.map((m) => ({ @@ -880,6 +890,8 @@ if (stopResponseFlag) { controller.abort('User: Stop Response'); } else { + const messages = createMessagesList(responseMessageId); + const res = await chatCompleted(localStorage.token, { model: model, messages: messages.map((m) => ({