-
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.
Merge pull request #2470 from janhq/chore/load-unload-model-sync
- Loading branch information
Showing
46 changed files
with
742 additions
and
574 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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
core/src/extensions/assistant.ts → core/src/browser/extensions/assistant.ts
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
2 changes: 1 addition & 1 deletion
2
core/src/extensions/conversational.ts → .../src/browser/extensions/conversational.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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 instance of the engine manager. | ||
*/ | ||
static instance(): EngineManager { | ||
return window.core?.engineManager as 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { OAIEngine } from './OAIEngine' | ||
|
||
/** | ||
* Base OAI Remote Inference Provider | ||
* Added the implementation of loading and unloading model (applicable to local inference providers) | ||
*/ | ||
export abstract class RemoteOAIEngine extends OAIEngine { | ||
// The inference engine | ||
abstract apiKey: string | ||
/** | ||
* On extension load, subscribe to events. | ||
*/ | ||
override onLoad() { | ||
super.onLoad() | ||
} | ||
|
||
/** | ||
* Headers for the inference request | ||
*/ | ||
override headers(): HeadersInit { | ||
return { | ||
'Authorization': `Bearer ${this.apiKey}`, | ||
'api-key': `${this.apiKey}`, | ||
} | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
core/src/extensions/huggingface.ts → core/src/browser/extensions/huggingface.ts
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
2 changes: 1 addition & 1 deletion
2
core/src/extensions/inference.ts → core/src/browser/extensions/inference.ts
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
2 changes: 1 addition & 1 deletion
2
core/src/extensions/model.ts → core/src/browser/extensions/model.ts
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
2 changes: 1 addition & 1 deletion
2
core/src/extensions/monitoring.ts → core/src/browser/extensions/monitoring.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Export Core module | ||
* @module | ||
*/ | ||
export * from './core' | ||
|
||
/** | ||
* Export Event module. | ||
* @module | ||
*/ | ||
export * from './events' | ||
|
||
/** | ||
* Export Filesystem module. | ||
* @module | ||
*/ | ||
export * from './fs' | ||
|
||
/** | ||
* Export Extension module. | ||
* @module | ||
*/ | ||
export * from './extension' | ||
|
||
/** | ||
* Export all base extensions. | ||
* @module | ||
*/ | ||
export * from './extensions' | ||
|
||
/** | ||
* Export all base tools. | ||
* @module | ||
*/ | ||
export * from './tools' |
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,2 @@ | ||
export * from './manager' | ||
export * from './tool' |
Oops, something went wrong.