Timothy J. Baek 8 months ago
parent
commit
7b91be21b4

+ 1 - 1
src/lib/components/chat/MessageInput.svelte

@@ -280,7 +280,7 @@
 			<div class="w-full relative">
 			<div class="w-full relative">
 				{#if atSelectedModel !== undefined}
 				{#if atSelectedModel !== undefined}
 					<div
 					<div
-						class="px-3 py-2.5 text-left w-full flex justify-between items-center absolute bottom-0 left-0 right-0 bg-gradient-to-t from-50% from-white dark:from-gray-900 z-10"
+						class="px-3 py-2.5 text-left w-full flex justify-between items-center absolute bottom-0.5 left-0 right-0 bg-gradient-to-t from-50% from-white dark:from-gray-900 z-10"
 					>
 					>
 						<div class="flex items-center gap-2 text-sm dark:text-gray-500">
 						<div class="flex items-center gap-2 text-sm dark:text-gray-500">
 							<img
 							<img

+ 4 - 4
src/lib/components/chat/MessageInput/Commands/Documents.svelte

@@ -2,7 +2,7 @@
 	import { createEventDispatcher } from 'svelte';
 	import { createEventDispatcher } from 'svelte';
 
 
 	import { documents } from '$lib/stores';
 	import { documents } from '$lib/stores';
-	import { removeFirstHashWord, isValidHttpUrl } from '$lib/utils';
+	import { removeLastWordFromString, isValidHttpUrl } from '$lib/utils';
 	import { tick, getContext } from 'svelte';
 	import { tick, getContext } from 'svelte';
 	import { toast } from 'svelte-sonner';
 	import { toast } from 'svelte-sonner';
 
 
@@ -79,7 +79,7 @@
 	const confirmSelect = async (doc) => {
 	const confirmSelect = async (doc) => {
 		dispatch('select', doc);
 		dispatch('select', doc);
 
 
-		prompt = removeFirstHashWord(prompt);
+		prompt = removeLastWordFromString(prompt, command);
 		const chatInputElement = document.getElementById('chat-textarea');
 		const chatInputElement = document.getElementById('chat-textarea');
 
 
 		await tick();
 		await tick();
@@ -90,7 +90,7 @@
 	const confirmSelectWeb = async (url) => {
 	const confirmSelectWeb = async (url) => {
 		dispatch('url', url);
 		dispatch('url', url);
 
 
-		prompt = removeFirstHashWord(prompt);
+		prompt = removeLastWordFromString(prompt, command);
 		const chatInputElement = document.getElementById('chat-textarea');
 		const chatInputElement = document.getElementById('chat-textarea');
 
 
 		await tick();
 		await tick();
@@ -101,7 +101,7 @@
 	const confirmSelectYoutube = async (url) => {
 	const confirmSelectYoutube = async (url) => {
 		dispatch('youtube', url);
 		dispatch('youtube', url);
 
 
-		prompt = removeFirstHashWord(prompt);
+		prompt = removeLastWordFromString(prompt, command);
 		const chatInputElement = document.getElementById('chat-textarea');
 		const chatInputElement = document.getElementById('chat-textarea');
 
 
 		await tick();
 		await tick();

+ 4 - 1
src/lib/utils/index.ts

@@ -297,7 +297,10 @@ export const removeLastWordFromString = (inputString, wordString) => {
 	}
 	}
 
 
 	// Join the remaining words back into a string
 	// Join the remaining words back into a string
-	const resultString = words.join(' ');
+	let resultString = words.join(' ');
+	if (resultString !== '') {
+		resultString += ' ';
+	}
 
 
 	return resultString;
 	return resultString;
 };
 };