Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switch between models get stuck #2698

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/browser/extensions/engines/LocalOAIEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {})
})
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/inference-nitro-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions extensions/inference-nitro-extension/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
})
Expand Down
Loading