chore: attempt to stop model before switching engine variant
This commit is contained in:
parent
687b034b06
commit
713926e68c
@ -71,18 +71,6 @@ function dispose() {
|
||||
watchdog?.terminate()
|
||||
}
|
||||
|
||||
function addEnvPaths(dest: string) {
|
||||
// Add engine path to the PATH and LD_LIBRARY_PATH
|
||||
if (process.platform === 'win32') {
|
||||
process.env.PATH = (process.env.PATH || '').concat(path.delimiter, dest)
|
||||
} else {
|
||||
process.env.LD_LIBRARY_PATH = (process.env.LD_LIBRARY_PATH || '').concat(
|
||||
path.delimiter,
|
||||
dest
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cortex process info
|
||||
*/
|
||||
|
||||
@ -26,6 +26,7 @@ import { formatDownloadPercentage } from '@/utils/converter'
|
||||
import ExtensionSetting from '../ExtensionSetting'
|
||||
|
||||
import DeleteEngineVariant from './DeleteEngineVariant'
|
||||
import { useActiveModel } from '@/hooks/useActiveModel'
|
||||
const os = () => {
|
||||
switch (PLATFORM) {
|
||||
case 'win32':
|
||||
@ -52,6 +53,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
||||
const [installingEngines, setInstallingEngines] = useState<
|
||||
Map<string, number>
|
||||
>(new Map())
|
||||
const { stopModel } = useActiveModel()
|
||||
|
||||
const isEngineUpdated =
|
||||
latestReleasedEngine &&
|
||||
@ -104,6 +106,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
||||
|
||||
const handleEngineUpdate = useCallback(
|
||||
(event: { id: string; type: DownloadEvent; percent: number }) => {
|
||||
stopModel()
|
||||
mutateInstalledEngines()
|
||||
mutateDefaultEngineVariant()
|
||||
// Backward compatible support - cortex.cpp returns full variant file name
|
||||
@ -138,6 +141,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
||||
})
|
||||
},
|
||||
[
|
||||
stopModel,
|
||||
mutateDefaultEngineVariant,
|
||||
mutateInstalledEngines,
|
||||
setInstallingEngines,
|
||||
@ -153,6 +157,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
||||
}, [handleEngineUpdate])
|
||||
|
||||
const handleChangeVariant = (e: string) => {
|
||||
stopModel()
|
||||
setSelectedVariants(e)
|
||||
setDefaultEngineVariant(engine, {
|
||||
variant: e,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user