From 3b7775a5356ddb5e0a3c95cb633824ae9d1edf25 Mon Sep 17 00:00:00 2001 From: Brandon Hulston Date: Mon, 15 Jan 2024 17:58:51 -0700 Subject: [PATCH] Fix chat import bug --- src/lib/components/chat/SettingsModal.svelte | 2 +- src/routes/(app)/c/[id]/+page.svelte | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 841cf9a3..35ad9f1a 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -141,7 +141,7 @@ const importChats = async (_chats) => { for (const chat of _chats) { console.log(chat); - await createNewChat(localStorage.token, chat); + await createNewChat(localStorage.token, chat.chat); } await chats.set(await getChatList(localStorage.token)); diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 7fb82955..5c4c5f8e 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -7,7 +7,7 @@ import { page } from '$app/stores'; import { models, modelfiles, user, settings, chats, chatId, config } from '$lib/stores'; - import { copyToClipboard, splitStream } from '$lib/utils'; + import { copyToClipboard, splitStream, convertMessagesToHistory } from '$lib/utils'; import { generateChatCompletion, generateTitle } from '$lib/apis/ollama'; import { createNewChat, getChatById, getChatList, updateChatById } from '$lib/apis/chats'; @@ -95,6 +95,8 @@ }); if (chat) { + console.log("Chat from getChatById1", chat) //Remove + console.log("Chat from getChatById2", chat.chat); // Remove const chatContent = chat.chat; if (chatContent) { @@ -103,7 +105,7 @@ selectedModels = (chatContent?.models ?? undefined) !== undefined ? chatContent.models - : [chatContent.model ?? '']; + : [chatContent.models ?? '']; history = (chatContent?.history ?? undefined) !== undefined ? chatContent.history