From 59724ea9d80c5502f23b4b0545611a45aebbd759 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 17 Jan 2024 15:09:38 -0800 Subject: [PATCH 1/3] feat: message ts --- src/routes/(app)/+page.svelte | 9 ++++++--- src/routes/(app)/c/[id]/+page.svelte | 26 ++++++++++++-------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 70320093..2a13d020 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -145,7 +145,8 @@ role: 'user', user: _user ?? undefined, content: userPrompt, - files: files.length > 0 ? files : undefined + files: files.length > 0 ? files : undefined, + timestamp: Date.now() }; // Add message to history and Set currentId to messageId @@ -256,7 +257,8 @@ childrenIds: [], role: 'assistant', content: '', - model: model + model: model, + timestamp: Date.now() }; // Add message to history and Set currentId to messageId @@ -446,7 +448,8 @@ childrenIds: [], role: 'assistant', content: '', - model: model + model: model, + timestamp: Date.now() }; history.messages[responseMessageId] = responseMessage; diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index c4774aaa..fffdd213 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -135,8 +135,7 @@ // Ollama functions ////////////////////////// - const submitPrompt = async (userPrompt, user) => { - console.log(userPrompt, user); + const submitPrompt = async (userPrompt, _user = null) => { console.log('submitPrompt', $chatId); if (selectedModels.includes('')) { @@ -163,8 +162,10 @@ parentId: messages.length !== 0 ? messages.at(-1).id : null, childrenIds: [], role: 'user', + user: _user ?? undefined, content: userPrompt, - files: files.length > 0 ? files : undefined + files: files.length > 0 ? files : undefined, + timestamp: Date.now() }; // Add message to history and Set currentId to messageId @@ -200,15 +201,7 @@ await chatId.set('local'); } await tick(); - } else if (chat.chat["models"] != selectedModels) { - // If model is not saved in DB, then save selectedmodel when message is sent - - chat = await updateChatById(localStorage.token, $chatId, { - models: selectedModels - }); - await chats.set(await getChatList(localStorage.token)); } - // Reset chat input textarea prompt = ''; files = []; @@ -282,7 +275,8 @@ childrenIds: [], role: 'assistant', content: '', - model: model + model: model, + timestamp: Date.now() }; // Add message to history and Set currentId to messageId @@ -472,7 +466,8 @@ childrenIds: [], role: 'assistant', content: '', - model: model + model: model, + timestamp: Date.now() }; history.messages[responseMessageId] = responseMessage; @@ -703,7 +698,10 @@
- 0 && !selectedModels.includes('')} /> + 0 && !selectedModels.includes('')} + />
From 4ec81a897e2de087bf316d5c4046db35f816217d Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 17 Jan 2024 17:43:45 -0800 Subject: [PATCH 2/3] feat: message ts display --- src/lib/components/chat/Messages/Name.svelte | 2 +- src/lib/components/chat/Messages/ResponseMessage.svelte | 7 +++++++ src/lib/components/chat/Messages/UserMessage.svelte | 8 ++++++++ src/routes/(app)/+page.svelte | 6 +++--- src/routes/(app)/c/[id]/+page.svelte | 6 +++--- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/lib/components/chat/Messages/Name.svelte b/src/lib/components/chat/Messages/Name.svelte index 4638e3b7..dea6ef84 100644 --- a/src/lib/components/chat/Messages/Name.svelte +++ b/src/lib/components/chat/Messages/Name.svelte @@ -1,3 +1,3 @@ -
+
diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 4dfcd61d..aa3f30b5 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -1,4 +1,5 @@