소스 검색

refac: tools behaviour

Timothy Jaeryang Baek 5 달 전
부모
커밋
393ab5d457
2개의 변경된 파일7개의 추가작업 그리고 6개의 파일을 삭제
  1. 4 4
      src/lib/components/chat/Chat.svelte
  2. 3 2
      src/lib/components/chat/MessageInput/InputMenu.svelte

+ 4 - 4
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'));

+ 3 - 2
src/lib/components/chat/MessageInput/InputMenu.svelte

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