-
Notifications
You must be signed in to change notification settings - Fork 935
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ServiceWorker] Reload model when service worker killed (#471)
Service worker may be killed by the browser despite us sending `keepAlive` messages. Upon killed, all states in the worker thread is lost. When the frontend sends another request, expecting the model loaded, the backend MLCEngine throws an error, essentially due to the mismatch of frontend's expectation and backend's reality. This PR adds `modelId` and `chatOpts` to `WebWorkerMLCEngine` (hence ServiceWorker and ExtensionServiceWorker), with the semantics being: the model and config that the frontend expects the backend to be currently loaded with. When sending a request, we send the expectation as well. For backend, upon receiving the chat completion request, it compares the expectation with its current state. If not matched (due to service worker killed), we reload before carrying out the request. --------- Co-authored-by: Nestor Qin <imba.qxy@gmail.com>
- Loading branch information
1 parent
74ed3be
commit e9b83b6
Showing
4 changed files
with
188 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters