From 7b91be21b497694ccef94ee0b9c2dfd52f3924ac Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 23 Aug 2024 14:43:32 +0200 Subject: [PATCH] refac --- src/lib/components/chat/MessageInput.svelte | 2 +- .../chat/MessageInput/Commands/Documents.svelte | 8 ++++---- src/lib/utils/index.ts | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index a71578513..f0d51aa9a 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -280,7 +280,7 @@
{#if atSelectedModel !== undefined}
{ dispatch('select', doc); - prompt = removeFirstHashWord(prompt); + prompt = removeLastWordFromString(prompt, command); const chatInputElement = document.getElementById('chat-textarea'); await tick(); @@ -90,7 +90,7 @@ const confirmSelectWeb = async (url) => { dispatch('url', url); - prompt = removeFirstHashWord(prompt); + prompt = removeLastWordFromString(prompt, command); const chatInputElement = document.getElementById('chat-textarea'); await tick(); @@ -101,7 +101,7 @@ const confirmSelectYoutube = async (url) => { dispatch('youtube', url); - prompt = removeFirstHashWord(prompt); + prompt = removeLastWordFromString(prompt, command); const chatInputElement = document.getElementById('chat-textarea'); await tick(); diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 56922f03f..995712dfa 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -297,7 +297,10 @@ export const removeLastWordFromString = (inputString, wordString) => { } // Join the remaining words back into a string - const resultString = words.join(' '); + let resultString = words.join(' '); + if (resultString !== '') { + resultString += ' '; + } return resultString; };