refac: tools behaviour

This commit is contained in:
Timothy Jaeryang Baek 2024-11-16 18:10:01 -08:00
parent c35f8c9673
commit 393ab5d457
2 changed files with 7 additions and 6 deletions

View File

@ -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'));

View File

@ -89,9 +89,10 @@
<div class=" flex-shrink-0">
<Switch
state={tools[toolId].enabled}
on:change={async () => {
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);