diff --git a/web/containers/DropdownListSidebar/index.tsx b/web/containers/DropdownListSidebar/index.tsx index 5f736aae7..d2eed48eb 100644 --- a/web/containers/DropdownListSidebar/index.tsx +++ b/web/containers/DropdownListSidebar/index.tsx @@ -50,7 +50,7 @@ export default function DropdownListSidebar() { const threadStates = useAtomValue(threadStatesAtom) const [selectedModel, setSelectedModel] = useAtom(selectedModelAtom) const setThreadModelParams = useSetAtom(setThreadModelParamsAtom) - const { activeModel, startModel, stateModel } = useActiveModel() + const { activeModel, startModel, stateModel, stopModel } = useActiveModel() const [serverEnabled, setServerEnabled] = useAtom(serverEnabledAtom) const { setMainViewState } = useMainViewState() @@ -142,12 +142,14 @@ export default function DropdownListSidebar() { }, [stateModel.loading, loader]) const onValueSelected = useCallback( - (modelId: string) => { + async (modelId: string) => { const model = downloadedModels.find((m) => m.id === modelId) setSelectedModel(model) + await stopModel() + if (activeModel?.id !== modelId) { - startModel(modelId) + await startModel(modelId) } if (serverEnabled) { @@ -168,6 +170,7 @@ export default function DropdownListSidebar() { downloadedModels, serverEnabled, activeThreadId, + activeModel, setSelectedModel, setThreadModelParams, ] @@ -184,7 +187,7 @@ export default function DropdownListSidebar() {