From 7748f0c7e1968832c71ca0e9a1a3a75ab9b36dd9 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 5 May 2025 10:45:56 +0700 Subject: [PATCH] fix: local model run --- web/containers/Providers/ModelHandler.tsx | 3 +-- web/hooks/useSendChatMessage.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/web/containers/Providers/ModelHandler.tsx b/web/containers/Providers/ModelHandler.tsx index 822a94b87..1ae36fb57 100644 --- a/web/containers/Providers/ModelHandler.tsx +++ b/web/containers/Providers/ModelHandler.tsx @@ -48,8 +48,7 @@ export default function ModelHandler() { const addNewMessage = useSetAtom(addNewMessageAtom) const updateMessage = useSetAtom(updateMessageAtom) const downloadedModels = useAtomValue(downloadedModelsAtom) - const activeModel = useAtomValue(activeModelAtom) - const setActiveModel = useSetAtom(activeModelAtom) + const [activeModel, setActiveModel] = useAtom(activeModelAtom) const setStateModel = useSetAtom(stateModelAtom) const subscribedGeneratingMessage = useAtomValue( subscribedGeneratingMessageAtom diff --git a/web/hooks/useSendChatMessage.ts b/web/hooks/useSendChatMessage.ts index 58a1ebfcc..cd6ff2692 100644 --- a/web/hooks/useSendChatMessage.ts +++ b/web/hooks/useSendChatMessage.ts @@ -143,14 +143,14 @@ export default function useSendChatMessage( const activeThread = activeThreadRef.current const activeAssistant = activeAssistantRef.current - const activeModel = selectedModelRef.current + const currentModel = selectedModelRef.current if (!activeThread || !activeAssistant) { console.error('No active thread or assistant') return } - if (!activeModel?.id) { + if (!currentModel?.id) { setModelDropdownState(true) return } @@ -179,9 +179,9 @@ export default function useSendChatMessage( // Fallback support for previous broken threads if (activeAssistant.model?.id === '*') { activeAssistant.model = { - id: activeModel.id, - settings: activeModel.settings, - parameters: activeModel.parameters, + id: currentModel.id, + settings: currentModel.settings, + parameters: currentModel.parameters, } } if (runtimeParams.stream == null) { @@ -254,7 +254,7 @@ export default function useSendChatMessage( setFileUpload(undefined) } - if (activeModel?.id !== modelId && modelId) { + if (modelRef.current?.id !== modelId && modelId) { const error = await startModel(modelId).catch((error: Error) => error) if (error) { updateThreadWaiting(activeThread.id, false)