fix: stop button is gone after switching to a new model (#4356)
This commit is contained in:
parent
9b8d8ab3f7
commit
81ad90b951
@ -204,6 +204,14 @@ export const resetThreadWaitingForResponseAtom = atom(null, (get, set) => {
|
|||||||
set(threadStatesAtom, currentState)
|
set(threadStatesAtom, currentState)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset all generating states
|
||||||
|
**/
|
||||||
|
export const resetGeneratingResponseAtom = atom(null, (get, set) => {
|
||||||
|
set(resetThreadWaitingForResponseAtom)
|
||||||
|
set(isGeneratingResponseAtom, false)
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the thread last message
|
* Update the thread last message
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -38,10 +38,6 @@ export function useActiveModel() {
|
|||||||
const pendingModelLoad = useRef(false)
|
const pendingModelLoad = useRef(false)
|
||||||
const isVulkanEnabled = useAtomValue(vulkanEnabledAtom)
|
const isVulkanEnabled = useAtomValue(vulkanEnabledAtom)
|
||||||
const activeAssistant = useAtomValue(activeAssistantAtom)
|
const activeAssistant = useAtomValue(activeAssistantAtom)
|
||||||
const setGeneratingResponse = useSetAtom(isGeneratingResponseAtom)
|
|
||||||
const resetThreadWaitingForResponseState = useSetAtom(
|
|
||||||
resetThreadWaitingForResponseAtom
|
|
||||||
)
|
|
||||||
|
|
||||||
const downloadedModelsRef = useRef<Model[]>([])
|
const downloadedModelsRef = useRef<Model[]>([])
|
||||||
|
|
||||||
@ -147,8 +143,6 @@ export function useActiveModel() {
|
|||||||
return
|
return
|
||||||
|
|
||||||
const engine = EngineManager.instance().get(stoppingModel.engine)
|
const engine = EngineManager.instance().get(stoppingModel.engine)
|
||||||
setGeneratingResponse(false)
|
|
||||||
resetThreadWaitingForResponseState()
|
|
||||||
return engine
|
return engine
|
||||||
?.unloadModel(stoppingModel)
|
?.unloadModel(stoppingModel)
|
||||||
.catch((e) => console.error(e))
|
.catch((e) => console.error(e))
|
||||||
@ -158,14 +152,7 @@ export function useActiveModel() {
|
|||||||
pendingModelLoad.current = false
|
pendingModelLoad.current = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[
|
[activeModel, setStateModel, setActiveModel, stateModel]
|
||||||
activeModel,
|
|
||||||
setStateModel,
|
|
||||||
setActiveModel,
|
|
||||||
stateModel,
|
|
||||||
setGeneratingResponse,
|
|
||||||
resetThreadWaitingForResponseState,
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const stopInference = useCallback(async () => {
|
const stopInference = useCallback(async () => {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import { activeAssistantAtom } from '@/helpers/atoms/Assistant.atom'
|
|||||||
import {
|
import {
|
||||||
activeThreadAtom,
|
activeThreadAtom,
|
||||||
engineParamsUpdateAtom,
|
engineParamsUpdateAtom,
|
||||||
|
resetGeneratingResponseAtom,
|
||||||
} from '@/helpers/atoms/Thread.atom'
|
} from '@/helpers/atoms/Thread.atom'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -24,6 +25,7 @@ const AssistantSetting: React.FC<Props> = ({ componentData }) => {
|
|||||||
const { updateThreadMetadata } = useCreateNewThread()
|
const { updateThreadMetadata } = useCreateNewThread()
|
||||||
const { stopModel } = useActiveModel()
|
const { stopModel } = useActiveModel()
|
||||||
const setEngineParamsUpdate = useSetAtom(engineParamsUpdateAtom)
|
const setEngineParamsUpdate = useSetAtom(engineParamsUpdateAtom)
|
||||||
|
const resetGenerating = useSetAtom(resetGeneratingResponseAtom)
|
||||||
|
|
||||||
const onValueChanged = useCallback(
|
const onValueChanged = useCallback(
|
||||||
(key: string, value: string | number | boolean | string[]) => {
|
(key: string, value: string | number | boolean | string[]) => {
|
||||||
@ -32,6 +34,7 @@ const AssistantSetting: React.FC<Props> = ({ componentData }) => {
|
|||||||
componentData.find((x) => x.key === key)?.requireModelReload ?? false
|
componentData.find((x) => x.key === key)?.requireModelReload ?? false
|
||||||
if (shouldReloadModel) {
|
if (shouldReloadModel) {
|
||||||
setEngineParamsUpdate(true)
|
setEngineParamsUpdate(true)
|
||||||
|
resetGenerating()
|
||||||
stopModel()
|
stopModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user