From 092884fec54c1957532e5bbb415e89e768a1a32f Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 2 Jan 2024 16:06:11 -0800 Subject: [PATCH] fix: chat general --- src/lib/components/chat/MessageInput.svelte | 2 +- src/lib/components/chat/ModelSelector.svelte | 7 +++++++ src/routes/(app)/+page.svelte | 8 ++++++-- src/routes/(app)/c/[id]/+page.svelte | 9 ++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 55683329..1468310d 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -298,7 +298,7 @@ id="chat-textarea" class=" dark:bg-gray-800 dark:text-gray-100 outline-none w-full py-3 px-2 {fileUploadEnabled ? '' - : ' pl-4'} rounded-xl resize-none" + : ' pl-4'} rounded-xl resize-none h-[48px]" placeholder={speechRecognitionListening ? 'Listening...' : 'Send a message'} bind:value={prompt} on:keypress={(e) => { diff --git a/src/lib/components/chat/ModelSelector.svelte b/src/lib/components/chat/ModelSelector.svelte index b4a0f47c..9e7ff4dd 100644 --- a/src/lib/components/chat/ModelSelector.svelte +++ b/src/lib/components/chat/ModelSelector.svelte @@ -1,5 +1,6 @@
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index b62a9caa..4e3347ff 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -109,10 +109,14 @@ await Promise.all( selectedModels.map(async (model) => { console.log(model); - if ($models.filter((m) => m.name === model)[0].external) { + const modelTag = $models.filter((m) => m.name === model).at(0); + + if (modelTag?.external) { await sendPromptOpenAI(model, prompt, parentId, _chatId); - } else { + } else if (modelTag) { await sendPromptOllama(model, prompt, parentId, _chatId); + } else { + toast.error(`Model ${model} not found`); } }) ); diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 48bc86ca..62c271bf 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -136,17 +136,20 @@ await Promise.all( selectedModels.map(async (model) => { console.log(model); - if ($models.filter((m) => m.name === model)[0].external) { + const modelTag = $models.filter((m) => m.name === model).at(0); + + if (modelTag?.external) { await sendPromptOpenAI(model, prompt, parentId, _chatId); - } else { + } else if (modelTag) { await sendPromptOllama(model, prompt, parentId, _chatId); + } else { + toast.error(`Model ${model} not found`); } }) ); await chats.set(await getChatList(localStorage.token)); }; - const sendPromptOllama = async (model, userPrompt, parentId, _chatId) => { // Create response message let responseMessageId = uuidv4();