-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: load, unload model and inference synchronously
- Loading branch information
Showing
11 changed files
with
163 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,30 @@ | ||
import { AIEngine } from './AIEngine' | ||
|
||
/** | ||
* Manages the registration and retrieval of inference engines. | ||
*/ | ||
export class EngineManager { | ||
public engines = new Map<string, AIEngine>() | ||
|
||
/** | ||
* Registers an engine. | ||
* @param engine - The engine to register. | ||
*/ | ||
register<T extends AIEngine>(engine: T) { | ||
this.engines.set(engine.provider, engine) | ||
} | ||
|
||
/** | ||
* Retrieves a engine by provider. | ||
* @param provider - The name of the engine to retrieve. | ||
* @returns The engine, if found. | ||
*/ | ||
get<T extends AIEngine>(provider: string): T | undefined { | ||
return this.engines.get(provider) as T | undefined | ||
} | ||
} | ||
|
||
/** | ||
* The singleton instance of the ExtensionManager. | ||
*/ | ||
export const engineManager = new EngineManager() |
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.