-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #697 from janhq/feat/add-model-event
feat: add model event
- Loading branch information
Showing
10 changed files
with
209 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export type ModelId = string; | ||
|
||
const ModelLoadingEvents = [ | ||
'starting', | ||
'stopping', | ||
'started', | ||
'stopped', | ||
'starting-failed', | ||
'stopping-failed', | ||
] as const; | ||
export type ModelLoadingEvent = (typeof ModelLoadingEvents)[number]; | ||
|
||
const AllModelStates = ['starting', 'stopping', 'started'] as const; | ||
export type ModelState = (typeof AllModelStates)[number]; | ||
|
||
export interface ModelStatus { | ||
model: ModelId; | ||
status: ModelState; | ||
metadata: Record<string, unknown>; | ||
} | ||
|
||
export interface ModelEvent { | ||
model: ModelId; | ||
event: ModelLoadingEvent; | ||
metadata: Record<string, unknown>; | ||
} | ||
|
||
export const EmptyModelEvent = {}; | ||
|
||
export interface ModelStatusAndEvent { | ||
data: { | ||
status: Record<ModelId, ModelStatus>; | ||
event: ModelEvent | typeof EmptyModelEvent; | ||
}; | ||
} |
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
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
Oops, something went wrong.