fix: switch between models get stuck at generating (#2698)

This commit is contained in:
Louis 2024-04-12 12:34:22 +07:00 committed by GitHub
parent d5946e68cd
commit fa9d8ab9a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -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, {})
})
}

View File

@ -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

View File

@ -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)
})
}
})