fix: switch between models get stuck at generating (#2698)
This commit is contained in:
parent
d5946e68cd
commit
fa9d8ab9a5
@ -53,11 +53,11 @@ export abstract class LocalOAIEngine extends OAIEngine {
|
||||
/**
|
||||
* Stops the model.
|
||||
*/
|
||||
override async unloadModel(model?: Model): Promise<void> {
|
||||
override async unloadModel(model?: Model) {
|
||||
if (model?.engine && model.engine?.toString() !== this.provider) return Promise.resolve()
|
||||
|
||||
this.loadedModel = undefined
|
||||
return executeOnMain(this.nodeModule, this.unloadModelFunctionName).then(() => {
|
||||
await executeOnMain(this.nodeModule, this.unloadModelFunctionName).then(() => {
|
||||
events.emit(ModelEvent.OnModelStopped, {})
|
||||
})
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ export default class JanInferenceNitroExtension extends LocalOAIEngine {
|
||||
return super.loadModel(model)
|
||||
}
|
||||
|
||||
override async unloadModel(model?: Model) {
|
||||
override async unloadModel(model?: Model): Promise<void> {
|
||||
if (model?.engine && model.engine !== this.provider) return
|
||||
|
||||
// stop the periocally health check
|
||||
|
||||
@ -323,14 +323,14 @@ async function killSubprocess(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
terminate(pid, function (err) {
|
||||
if (err) {
|
||||
return killRequest()
|
||||
killRequest().then(resolve).catch(reject)
|
||||
} else {
|
||||
return tcpPortUsed
|
||||
tcpPortUsed
|
||||
.waitUntilFree(PORT, NITRO_PORT_FREE_CHECK_INTERVAL, 5000)
|
||||
.then(() => resolve())
|
||||
.then(() => log(`[NITRO]::Debug: Nitro process is terminated`))
|
||||
.catch(() => {
|
||||
killRequest()
|
||||
killRequest().then(resolve).catch(reject)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user