From 120f8d778627b22bcd14d76f124552bc7688d69a Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 19 May 2024 05:53:43 -0700 Subject: [PATCH] refac: regenerate behaviour --- src/lib/components/chat/Messages.svelte | 7 ++++++- src/routes/(app)/+page.svelte | 6 +++++- src/routes/(app)/c/[id]/+page.svelte | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index 1a9ca373f..f805c83e3 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -355,7 +355,12 @@ copyToClipboard={copyToClipboardWithToast} {continueGeneration} {regenerateResponse} - on:change={() => { + on:change={async () => { + await updateChatById(localStorage.token, chatId, { + messages: messages, + history: history + }); + const element = document.getElementById('messages-container'); autoScroll = element.scrollHeight - element.scrollTop <= element.clientHeight + 50; diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 013f5d196..db3daf47a 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -766,7 +766,11 @@ let userMessage = history.messages[message.parentId]; let userPrompt = userMessage.content; - await sendPrompt(userPrompt, userMessage.id, message.model); + if ((userMessage?.models ?? [...selectedModels]).length == 1) { + await sendPrompt(userPrompt, userMessage.id); + } else { + await sendPrompt(userPrompt, userMessage.id, message.model); + } } }; diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index b002d9971..d330aadb3 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -771,7 +771,11 @@ let userMessage = history.messages[message.parentId]; let userPrompt = userMessage.content; - await sendPrompt(userPrompt, userMessage.id, message.model); + if ((userMessage?.models ?? [...selectedModels]).length == 1) { + await sendPrompt(userPrompt, userMessage.id); + } else { + await sendPrompt(userPrompt, userMessage.id, message.model); + } } };