From b916f1b07d89b9779e3dffd59d5560617fe98c52 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 29 Dec 2023 23:25:40 -0800 Subject: [PATCH] feat: messages refac --- src/lib/components/chat/Messages.svelte | 11 +++++++++++ .../components/chat/Messages/ResponseMessage.svelte | 13 +++---------- src/routes/(app)/c/[id]/+page.svelte | 13 ++++++++++++- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index 08589420..3920a40d 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -96,7 +96,17 @@ }; const confirmEditResponseMessage = async (messageId, content) => { + history.messages[messageId].originalContent = history.messages[messageId].content; history.messages[messageId].content = content; + + await tick(); + + await updateChatById(localStorage.token, chatId, { + messages: messages, + history: history + }); + + await chats.set(await getChatList(localStorage.token)); }; const rateMessage = async (messageId, rating) => { @@ -225,6 +235,7 @@ {:else} token/s: ${ `${ @@ -214,12 +207,12 @@
- +
- {#if selectedModelfile} - {selectedModelfile.title} + {#if message.model in modelfiles} + {modelfiles[message.model]?.title} {:else} Ollama {message.model ? ` ${message.model}` : ''} modelfile.tagName === selectedModels[0])[0] : null; + let selectedModelfiles = {}; + $: selectedModelfiles = selectedModels.reduce((a, tagName, i, arr) => { + const modelfile = + $modelfiles.filter((modelfile) => modelfile.tagName === tagName)?.at(0) ?? undefined; + + return { + ...a, + ...(modelfile && { [tagName]: modelfile }) + }; + }, {}); + let chat = null; let title = ''; @@ -643,7 +654,7 @@