From 393ab5d45722ec3251c4ec955236b04a9c21a7ca Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 16 Nov 2024 18:10:01 -0800 Subject: [PATCH] refac: tools behaviour --- src/lib/components/chat/Chat.svelte | 8 ++++---- src/lib/components/chat/MessageInput/InputMenu.svelte | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 1dab2af3e..e98ae5ca0 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -161,9 +161,6 @@ if (selectedModels.length !== 1) { return; } - - console.log('setToolIds', selectedModels); - const model = $models.find((m) => m.id === selectedModels[0]); if (model) { selectedToolIds = model?.info?.meta?.toolIds ?? []; @@ -830,9 +827,12 @@ console.log('submitPrompt', userPrompt, $chatId); const messages = createMessagesList(history.currentId); - selectedModels = selectedModels.map((modelId) => + const _selectedModels = selectedModels.map((modelId) => $models.map((m) => m.id).includes(modelId) ? modelId : '' ); + if (JSON.stringify(selectedModels) !== JSON.stringify(_selectedModels)) { + selectedModels = _selectedModels; + } if (userPrompt === '') { toast.error($i18n.t('Please enter a prompt')); diff --git a/src/lib/components/chat/MessageInput/InputMenu.svelte b/src/lib/components/chat/MessageInput/InputMenu.svelte index 8b5d5901d..2929428ca 100644 --- a/src/lib/components/chat/MessageInput/InputMenu.svelte +++ b/src/lib/components/chat/MessageInput/InputMenu.svelte @@ -89,9 +89,10 @@
{ + on:change={async (e) => { + const state = e.detail; await tick(); - if (tools[toolId].enabled) { + if (state) { selectedToolIds = [...selectedToolIds, toolId]; } else { selectedToolIds = selectedToolIds.filter((id) => id !== toolId);