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()
|
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
|
* Cortex process info
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import { formatDownloadPercentage } from '@/utils/converter'
|
|||||||
import ExtensionSetting from '../ExtensionSetting'
|
import ExtensionSetting from '../ExtensionSetting'
|
||||||
|
|
||||||
import DeleteEngineVariant from './DeleteEngineVariant'
|
import DeleteEngineVariant from './DeleteEngineVariant'
|
||||||
|
import { useActiveModel } from '@/hooks/useActiveModel'
|
||||||
const os = () => {
|
const os = () => {
|
||||||
switch (PLATFORM) {
|
switch (PLATFORM) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
@ -52,6 +53,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
const [installingEngines, setInstallingEngines] = useState<
|
const [installingEngines, setInstallingEngines] = useState<
|
||||||
Map<string, number>
|
Map<string, number>
|
||||||
>(new Map())
|
>(new Map())
|
||||||
|
const { stopModel } = useActiveModel()
|
||||||
|
|
||||||
const isEngineUpdated =
|
const isEngineUpdated =
|
||||||
latestReleasedEngine &&
|
latestReleasedEngine &&
|
||||||
@ -104,6 +106,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
|
|
||||||
const handleEngineUpdate = useCallback(
|
const handleEngineUpdate = useCallback(
|
||||||
(event: { id: string; type: DownloadEvent; percent: number }) => {
|
(event: { id: string; type: DownloadEvent; percent: number }) => {
|
||||||
|
stopModel()
|
||||||
mutateInstalledEngines()
|
mutateInstalledEngines()
|
||||||
mutateDefaultEngineVariant()
|
mutateDefaultEngineVariant()
|
||||||
// Backward compatible support - cortex.cpp returns full variant file name
|
// Backward compatible support - cortex.cpp returns full variant file name
|
||||||
@ -138,6 +141,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
|
stopModel,
|
||||||
mutateDefaultEngineVariant,
|
mutateDefaultEngineVariant,
|
||||||
mutateInstalledEngines,
|
mutateInstalledEngines,
|
||||||
setInstallingEngines,
|
setInstallingEngines,
|
||||||
@ -153,6 +157,7 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
|
|||||||
}, [handleEngineUpdate])
|
}, [handleEngineUpdate])
|
||||||
|
|
||||||
const handleChangeVariant = (e: string) => {
|
const handleChangeVariant = (e: string) => {
|
||||||
|
stopModel()
|
||||||
setSelectedVariants(e)
|
setSelectedVariants(e)
|
||||||
setDefaultEngineVariant(engine, {
|
setDefaultEngineVariant(engine, {
|
||||||
variant: e,
|
variant: e,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user